C | String | Question 11
Predict the output of the following program:
Take a step-up from those "Hello World" programs. Learn to implement data structures like Heap, Stacks, Linked List and many more! Check out our Data Structures in C course to start learning today.
#include <stdio.h>int main(){ char str[] = "%d %c", arr[] = "GeeksQuiz"; printf(str, 0[arr], 2[arr + 3]); return 0;} |
(A) G Q
(B) 71 81
(C) 71 Q
(D) Compile-time error
Answer: (C)
Explanation:
The statement printf(str, 0[arr], 2[arr + 3]); boils down to:
printf("%d %c, 0["GeeksQUiz"], 2["GeeksQUiz" + 3]);
Which is further interpreted as:
printf("%d %c, *(0 + "GeeksQUiz"), *(2 + "GeeksQUiz" + 3));
Which prints the ascii value of 'G' and character 'Q'.



