GATE Computer ScienceVery hardGATE CS (PYQ pattern)

int a[4][3] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}; int (*p)[3] = a; p += 2; int *q = *p + 1; printf("%d %d %d %d", *(*(p - 1) + 2), (*p)[1], q[-1], p[1][0]); What is printed?

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

Correct answer: A. 5 7 6 9

p += 2 makes p point to row 2 (values 6, 7, 8). *(*(p-1)+2) = a[1][2] = 5; (*p)[1] = 7; q = &a[2][1] so q[-1] = a[2][0] = 6; p[1][0] = a[3][0] = 9.

More Programming and Data Structures (GATE) questions

Exams that ask this topic