ProgrammingModerateAccenture · Cognizant pattern

What is printed?

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

Correct answer: B. 20

q points to p, and p points to x, so **q is x itself. Assigning 20 through **q changes x to 20.

More C Programming questions

Exams that ask this topic