I am sure you know what is declaration, what is definition and what is "extern". If you do not know then i will suggest this link for you, Read this and you will be through.
Now Let me explain, the output just in your program.
main()
{
{
extern int i; // This line declare the variable i, but it doe not
// allocate memory location. It say that "i" is a variable
// of type int and its somewhere in the program.
int i=20; // This line is the definition for the above declaration. Now
// Memory for "i" is allocated here and assigned the value 20
{
const volatile unsigned i=30; //Here "const" make variable i constant
// volatile is another keyword used in the C
// program which means that value of i can be
// chenged by compiler for optimization purpose
printf("%d",i); // This will print local i, which is 30
}
printf("%d",i); // This will print local i, here local i is 20
}
printf("%d",i); // This will access global i. hence print 0
}
int i; //Global i. since we have not assigned any value to this variable, compiler
// assigned 0 to this i
// Hence you get output 30 20 0
See, Its a very simple and straight forward question. As I always say that whenever you see a question then ask yourself why this question. So for this question why is : Static scoping. extern storage class, default initial value of global variable, use of const and volatile, difference of declaration and definition. Hope this help. Cheers.