GATE Computer ScienceModerateNIELIT · GATE CSE

int a[6] = {2, 4, 6, 8, 10, 12}; int *p = a + 1, *q = a + 5; What does printf("%ld %d", (long)(q - p), *(p + (q - p) / 2)); print?

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

Correct answer: A. 4 8

q − p = 4 elements; p + 2 = a + 3, whose value is 8.

More Programming and Data Structures (GATE) questions

Exams that ask this topic