ProgrammingHardGATE CS · TCS NQT

What does this C program print? int a[2][3] = {{1,2,3},{4,5,6}}; int (*p)[3] = a; printf("%d %d", (*(p+1))[1], **(p+1) + *(*p+2));

  1. A. 4 7
  2. B. 5 6
  3. C. 5 7
  4. D. 2 7

Correct answer: C. 5 7

p+1 points to row 1, so (*(p+1))[1] = a[1][1] = 5. **(p+1) = a[1][0] = 4 and *(*p+2) = a[0][2] = 3, so the second value is 7.

More C Programming questions

Exams that ask this topic