ProgrammingHardWipro · Cognizant pattern

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

Assume a 64-bit LP64 ABI. What is printed?
int x = 100;
int *p = &x;
int **pp = &p;
int ***ppp = &pp;
***ppp = 200;
printf("%d %d", x, **pp);
  1. A. 100 200
  2. B. 200 100
  3. C. 100 100
  4. D. 200 200

Correct answer: D. 200 200

ppp points to pp, pp points to p, p points to x. ***ppp dereferences three levels to reach x itself and assigns 200 to it. **pp also dereferences two levels (pp->p->x) and now reads the updated x, 200. Both reads show 200.

More C Programming questions

Exams that ask this topic