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
Can a variable be both static and volatile in c?
What does %d do?
Explain what is a 'null pointer assignment' error? Explain what are bus errors, memory faults, and core dumps?
Is it fine to write void main () or main () in c?
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)
what is the format specifier for printing a pointer value?
How would you use the functions fseek(), freed(), fwrite() and ftell()?
How can I manipulate strings of multibyte characters?
What is null in c?
What is openmp in c?
Differentiate between calloc and malloc.
What is spark map function?
Why c is procedure oriented?
what do u mean by Direct access files? then can u explain about Direct Access Files?
What is zero based addressing?