GATE 2011 CS (CS1) – Question 32
What is printed?
char c[]="GATE2011";
char *p=c;
printf("%s",p+p[3]-p[1]);Practise this question in The GATE Grind →
Show answer and explanation
Correct answer: (C) 2011
Explanation
Under the paper’s ASCII convention, p[3]=E and p[1]=A differ by 69−65=4. The argument is p+4, pointing to the substring after GATE. Printing that null-terminated suffix yields 2011, C.