Here you need to understand about linkage. There is internal linkage and there is external linkage.
External linkage allows you to use the variable in more than one file. Internal linkage allows you to use the variable in only the file where it is created.
By default the linkage of global variables is external.
So this code:
tells the compiler not to create a variable i because there is one already in another file that as external linkage.
This tells the compiler to create a variable i with an initial value of 10. The extern here for external linkage is not necessary since linkage of global variables is external by default.
This code says t create a variable i with an initial value of zero and with internal linkage. This variable is inaccessible outside the file where the variable is created. An extern i in another file cannot access this variable.
As to why global variables in the first place read this:
http://bytes.com/topic/c/insights/73...obal-variables