WHERE WE CAN ACCESS A VARIABLE...
void main()
{
int a=10;
printf("%d\n",a);
{
int b=20;
printf("%d,%d\n",a,b);
}
printf("%d,%d",a,b); /*error: b not
accesible */
}
EXPALNATION:
A variable defined in a block can be accessed in that block
and all its inner blocks (i.r., a variable defined in a block cannot be
accessed in its outer block).It is called as the scope of a variable .
No comments:
Post a Comment