ProgrammingVery hardProduct company OA · GATE CS

What is printed?

What is printed?
int a = 1, b = 2, c = 3;
int *arr[] = {&a, &b, &c};
int **pp = arr + 1;
**pp += 10;
*pp[1] += 20;
printf("%d %d %d", a, b, c);
  1. A. 1 12 23
  2. B. 1 32 3
  3. C. 21 12 3
  4. D. 1 12 3

Correct answer: A. 1 12 23

pp points at arr[1], so **pp is b, which becomes 12. Subscripting binds tighter than *, so *pp[1] is *(pp[1]) = *arr[2], which is c, now 23. Reading it as (*pp)[1] would step past b inside no array, which is not what the code says.

More C Programming questions

Exams that ask this topic