ProgrammingVery hardIBM · Deloitte pattern

What is printed?

What is printed?
int a = 1, b = 2, c = 3;
int *arr[3] = {&a, &b, &c};
int **p = arr;
int ***pp = &p;
***pp += 100;
(*pp)++;
**pp += 100;
printf("%d %d %d", a, b, c);
  1. A. 101 2 3
  2. B. 101 102 3
  3. C. 1 102 3
  4. D. 101 202 3

Correct answer: B. 101 102 3

***pp is a (through p[0]=&a), so a becomes 101. (*pp)++ advances p itself to point at arr[1] (&b). Now **pp is b, so b becomes 102. c is never touched. Output: 101 102 3.

More C Programming questions

Exams that ask this topic