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 / guest

Fail 1,Fail 2

Is This Answer Correct ?    0 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is a const pointer?

712


Can i use “int” data type to store the value 32768? Why?

866


The file stdio.h, what does it contain?

773


How do you print an address?

850


What is call by reference in functions?

730






What is the use of extern in c?

740


What are the advantages of using macro in c language?

685


What are reserved words?

741


What is the difference between typedef and #define?

631


How can I implement sets or arrays of bits?

695


What is an auto keyword in c?

752


Is register a keyword in c?

737


Can a local variable be volatile in c?

665


Can two or more operators such as and be combined in a single line of program code?

923


What does the message "automatic aggregate intialization is an ansi feature" mean?

790