GATE Computer ScienceEasyGATE CS (PYQ pattern)

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

  1. A. 14 6 3
  2. B. 14 6 12
  3. C. 6 6 3
  4. D. 14 4 3

Correct answer: A. 14 6 3

*p = 4 and *q = 10 give 14; q - 2 points to a[2] = 6; q - p is the element difference 3, not a byte count.

More Programming and Data Structures (GATE) questions

Exams that ask this topic