ProgrammingHardHCL · Tech Mahindra pattern

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

Assume a 64-bit LP64 ABI. What is printed?
int a = 1;
int b = 2;
int *parr[2];
parr[0] = &a;
parr[1] = &b;
int **pp = parr;
for (int i = 0; i < 2; i++) {
    **(pp + i) *= 10;
}
printf("%d %d", a, b);
  1. A. 11 12
  2. B. 10 2
  3. C. 10 20
  4. D. 1 2

Correct answer: C. 10 20

pp+i steps through parr's two pointer slots; dereferencing twice (**) reaches the pointed-to int (a then b) and multiplies it by 10 in place, giving a=10 and b=20.

More C Programming questions

Exams that ask this topic