ProgrammingHardIBM · Deloitte pattern

What is printed?

What is printed?
int x = 10;
int *p = &x;
int **pp = &p;
**pp = 20;
*pp = NULL;
printf("%d %d", x, (p == NULL));
  1. A. Compilation error
  2. B. 20 1
  3. C. 20 0
  4. D. 10 1

Correct answer: B. 20 1

**pp = 20 dereferences through pp to p to x, setting x to 20. *pp = NULL then assigns NULL directly to p itself (pp still points at p's storage), making p == NULL true, but x already holds 20 from the earlier assignment.

More C Programming questions

Exams that ask this topic