ProgrammingHardGATE CS · Campus placements

int a[5] = {0}; int *p = a + 5; p[-1] = 7; printf("%d", a[4] + *(a + 4)); What is printed?

  1. A. 14
  2. B. 7
  3. C. 0
  4. D. 21

Correct answer: A. 14

a + 5 is a valid one-past-the-end pointer, and p[-1] writes a[4] = 7. Reading a[4] twice gives 7 + 7 = 14.

More C Programming questions

Exams that ask this topic