E02 Answer


a=1     b=3
a=1     b=2

int main( void )
{
  int a = 1;
  int b = 2;
  
  {
    int b = 3;
    printf("a=%d\tb=%d\n", a, b );
  }

  printf("a=%d\tb=%d\n", a, b );

  system("pause");
  return 0;
}

Comments: The variables a and b are declared at the beginning of the main block. Their scope starts at their declaration and continues to the end of the block.

However, there is an inner block, which starts out with a declaration of a variable, b. The scope of this b starts at its declaration and continues to the end of the inner block. It overrides the declaration of the first b.

In the nested statement

    printf("a=%d\tb=%d\n", a, b );

the identifier a refers to the a of the main block, but the identifier b refers to the b of the inner block.