ProgrammingHardWipro · Cognizant pattern

What is printed?

What is printed?
int a = 1, b = 2, c = 3;
int *arr[3] = {&a, &b, &c};
int **p = arr;
for (int i = 0; i < 3; i++) {
    **(p + i) *= 10;
}
printf("%d %d %d", a, b, c);
  1. A. 10 20 30
  2. B. 1 2 3
  3. C. 10 2 3
  4. D. 1 20 30

Correct answer: A. 10 20 30

p+i steps through arr, each *(p+i) is one of the stored pointers, and **(p+i) dereferences through to a, b or c in turn, multiplying each by 10.

More C Programming questions

Exams that ask this topic