ProgrammingModerate

int a[] = {10, 20, 30}; int *p = a; p++; printf("%d", *p + p[1]); What is printed?

  1. A. 40
  2. B. 60
  3. C. 50
  4. D. 30

Correct answer: C. 50

After p++, p points at a[1], so *p = 20 and p[1] = *(p + 1) = a[2] = 30, total 50. 30 forgets that p moved (10 + 20), and 40 adds 20 twice.

More C Programming questions

Exams that ask this topic