Multiple choice technology programming languages

What is the output of the following program ? main() { int a=10; { int a=100; { int a=1000; printf("%d", a); } printf("%d", a); } printf("%d", a); }

  1. 100010001000

  2. 100010010

  3. 101001000

  4. 010010001

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

C features block scope rules where variables declared in inner blocks shadow outer declarations. The innermost print statement prints the innermost a (1000), the next outer block prints its local a (100), and the outermost block prints the first a (10), resulting in the output string 100010010.