19.6.20

c macro: where we can access a variable


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

JAVA program pattern 2

import java.util.Scanner; public class pattern3 { public static void main(String args[]) { int i,j; Scanner sc=new Scanner(System.in); Syste...