ProgrammingHardIBM · Deloitte pattern

Assume a 64-bit LP64 ABI. What is printed?

Assume a 64-bit LP64 ABI. What is printed?
int a = 1, b = 2, c = 3;
int *arr[3] = {&a, &b, &c};
int **p = arr;
p++;
**p += 10;
printf("%d %d %d", a, b, c);
  1. A. 1 2 13
  2. B. 11 2 3
  3. C. 1 2 3
  4. D. 1 12 3

Correct answer: D. 1 12 3

p is a pointer to the array of pointers, starting at &arr[0]. p++ advances it to point at arr[1], which holds &b. **p dereferences p to get arr[1] (&b), then dereferences that to reach b itself, and += 10 adds 10 to b, making it 12. a and c are untouched.

More C Programming questions

Exams that ask this topic