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

Can a variable be both static and volatile in c?

604


What does %d do?

711


Explain what is a 'null pointer assignment' error? Explain what are bus errors, memory faults, and core dumps?

637


Is it fine to write void main () or main () in c?

543


Write a program that takes a 5 digit number and calculates 2 power that number and prints it(should not use big integers and exponential functions)

5790






what is the format specifier for printing a pointer value?

609


How would you use the functions fseek(), freed(), fwrite() and ftell()?

698


How can I manipulate strings of multibyte characters?

631


What is null in c?

596


What is openmp in c?

608


Differentiate between calloc and malloc.

751


What is spark map function?

578


Why c is procedure oriented?

565


what do u mean by Direct access files? then can u explain about Direct Access Files?

1637


What is zero based addressing?

706