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
c)Pass 1, Fail 2
| Is This Answer Correct ? | 1 Yes | 2 No |
Post New Answer View All Answers
How was c created?
What are type modifiers in c?
What is difference between static and global variable in c?
Why main is not a keyword in c?
What are the two types of structure?
Can you assign a different address to an array tag?
What is indirection? How many levels of pointers can you have?
How will you declare an array of three function pointers where each function receives two ints and returns a float?
What is the stack in c?
What is the use of define in c?
write a program to display all prime numbers
What is echo in c programming?
Which is not valid in C a) class aClass{public:int x;}; b) /* A comment */ c) char x=12;
How will you write a code for accessing the length of an array without assigning it to another variable?
What is the difference between NULL and NUL?