C local copy of block have higher priority



#include<stdio.h>

void main()
{
    int num = 20;
    {
        int num = 30 ;
        printf("%d ",num);
    }
    printf("%d ",num);
    return(0);
}

Output :

30 20

Explanation :

Consider the following inner block –

{
int num = 30 ;
printf("%d ",num);
}

Inner variable num is local variable of inner block. Though the variable have global copy, first priority is given to the local copy of the block. As soon as the block ends the local copy will be destroyed.

printf("%d ",num);
    return(0);