ProgrammingVery hardProduct company OA

What is printed?

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

Correct answer: A. 30 40

pp += 2 advances by 2 elements of arr (pointers), landing on arr[2] = &a[2]. **pp dereferences to a[2]=30. *pp is &a[2], so *(*pp+1) is a[3]=40.

More C Programming questions

Exams that ask this topic