Predict the output of the following program:
#include <stdio.h>
int main()
{
char str[] = "%d %c", arr[] = "GeeksQuiz";
printf(str, 0[arr], 2[arr + 3]);
return 0;
}
Answer: C
Correct answer: 71 Q
Both subscripts are written backwards, which is legal: 0[arr] is arr[0] = 'G', and 2[arr+3] is *(arr+3+2) = arr[5] = 'Q'. The format string, itself held in an array, prints the first with %d - giving the character code 71 - and the second with %c, giving Q.
Please log in or register to report this question.