ProgrammingHardTCS NQT · Infosys

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

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

Correct answer: B. 4

After p += 3 it points at a[3] = 4. The postfix decrement uses the old value, so 4 is printed and p moves back to a[2].

More C Programming questions

Exams that ask this topic