Nested Blocks
#include <stdio.h>
main()
{
int x = 1;
printf("%d\n", x);
{
int x=2, y=3;
printf("%d %d\n",
++x, y);
}
printf("%d\n", x);
}
prints:
1
3 3
1
y is visible only in this bock, inner x is not the same as outer x.
This is program
pg412.c
Previous slide
Next slide
Back to first slide
View graphic version