ProgrammingHard

int x = 1; { int x = 2; printf("%d", x); } printf("%d", x); What is printed?

  1. A. 12
  2. B. 21
  3. C. 22
  4. D. 11

Correct answer: B. 21

The inner block declares a new x that hides the outer one, so the first print is 2. After the block, x is 1 again.

More C Programming questions

Exams that ask this topic