GATE 2013 Comprehensive Information Page @ http://www.codeblocks.info/2012/08/gate-2013.html
What does the following fragment of C program print?
char c[] = "GATE2011";
char *p = c;
printf("%s", p + p[3] - p[1]);
(A) GATE2011(B) E2011
(C) 2011
(D) 011
Answer: (C) 2011
Explanation:
p[3] = A (Ascii = 65)
p[1] = E (Ascii = 69)
p[3] - p[1] = 4
p + p[3] - p[1] = p + 4
printf starts printing from the p + 4 till the end giving 2011
Written by Munia Balayil
No comments:
Post a Comment