ProgrammingHardTCS NQT · Infosys

int a[] = {4, 9, 16}; int *p = a; What is (p + 2)[-1]?

  1. A. 9
  2. B. 16
  3. C. 4
  4. D. undefined

Correct answer: A. 9

(p + 2)[-1] is *(p + 1), which is a[1] = 9. Indexing with a negative subscript is valid whenever the resulting address is inside the array.

More C Programming questions

Exams that ask this topic