-
What does the following fragment of C-program print?
char c[] = “GATE 2011”
char * p = c;
printf (“%s”, p + p[3] – p[1];
-
- GATE 2011
- E 2011
- 2011
- 011
- GATE 2011
Correct Option: C
2011 charc[] = "GATE2011";
p now has the base address string "GATE2011"
char*p =c;
p[3] is 'E' and p[1] is 'A'.
p[3] - p[1] = ASCII value of 'E' - ASCII value of 'A' = 4
So the expression p + p[3] - p[1] becomes p + 4 which is base address of string "2011