What will be the result of the following program?
main()
{
char p[]="String";
int x=0;

if(p=="String")
{
printf("Pass 1");
if(p[sizeof(p)-2]=='g')
printf("Pass 2");
else
printf("Fail 2");
}
else
{
printf("Fail 1");
if(p[sizeof(p)-2]=='g')
printf("Pass 2");
else
printf("Fail 2");
}
}

a) Pass 1, Pass 2
b) Fail 1, Fail 2
c) Pass 1, Fail 2
d) Fail 1, Pass 2
e) syntax error during compilation

Answer Posted / rakhi

b) Fail 1 Fail 2

Is This Answer Correct ?    2 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain the use of #pragma exit?

699


What are header files in c?

616


Can a program have two main functions?

570


Which one would you prefer - a macro or a function?

604


Why do we write return 0 in c?

553






Explain what is the difference between null and nul?

653


How we can insert comments in a c program?

630


Is it valid to address one element beyond the end of an array?

674


What is time complexity c?

568


Why does the call char scanf work?

619


What is the purpose of void in c?

619


What is the general form of a C program?

596


Who developed c language and when?

584


Is c is a procedural language?

599


Is it possible to execute code even after the program exits the main() function?

812