ProgrammingVery hardTCS NQT · C · Advanced

What is printed?

What is printed?
int m[3][3] = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};
int (*p)[3] = m + 1;
printf("%d %d %d", (*p)[2], p[1][0], (*(p - 1))[1]);
  1. A. 6 7 5
  2. B. 3 7 2
  3. C. 6 7 2
  4. D. 5 7 2

Correct answer: C. 6 7 2

p points at row 1; (*p)[2] = m[1][2] = 6, p[1][0] = m[2][0] = 7, and (*(p-1))[1] = m[0][1] = 2.

More C Programming questions

Exams that ask this topic