ProgrammingVery hardGATE CS · Campus placements

int a[3] = {1, 2, 3}; int *p = a; int (*q)[3] = &a; printf("%d", *(*q + 2) + *(p + 1)); What is printed?

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

Correct answer: D. 5

*q decays to a pointer to a[0], so *(*q + 2) is a[2] = 3. *(p + 1) is a[1] = 2, and 3 + 2 = 5.

More C Programming questions

Exams that ask this topic