ProgrammingHardProduct-company MCQ pattern

What is printed?

What is printed?
int a[3] = {1,2,3};
int *parr[3] = {a, a+1, a+2};
int **pp = parr;
*(*pp + 1) += 10;
printf("%d %d %d", a[0], a[1], a[2]);
  1. A. 11 2 3
  2. B. 1 2 13
  3. C. 1 12 3
  4. D. 1 2 3

Correct answer: C. 1 12 3

*pp is parr[0], which equals a (pointing at a[0]). *(*pp+1) dereferences a+1, i.e. a[1]; adding 10 makes a[1] become 12, leaving a[0] and a[2] untouched.

More C Programming questions

Exams that ask this topic