GATE Computer ScienceVery hardGATE CS (PYQ pattern)

int a[] = {10, 20, 30, 40}; int *p[] = {a, a + 1, a + 2, a + 3}; int **pp = p; int t1 = **pp++; int t2 = *++*pp; int t3 = ++**++pp; printf("%d %d %d %td", t1, t2, t3, pp - p); What is printed?

  1. A. 10 20 31 2
  2. B. 10 30 31 2
  3. C. 10 30 30 2
  4. D. 20 30 31 1

Correct answer: B. 10 30 31 2

pp++ yields p[0], so t1 = 10 and pp -> p[1]. *++*pp bumps p[1] itself to &a[2], so t2 = 30. ++pp makes pp -> p[2] = &a[2]; ++**pp makes a[2] = 31. pp - p = 2.

More Programming and Data Structures (GATE) questions

Exams that ask this topic