global variable in C

In C, a global variable is also called an external variable. The keyword extern means "the storage for this variable is allocated elsewhere". It tells the compiler "I'm referencing myGlobalvar here, and you haven't seen it before, but that's OK; the linker will know what you are talking about." You normally use extern when you want to refer to something that is not in the current translation unit, such as a variable that's defined in a library you will be linking to.

You should not define global variables in .h header files. You should define them in .c source file.
* If global variable is to be visible within only one .c file, you should declare it static.
* If global variable is to be used across multiple .c files, you should not declare it static. Instead you should declare it extern in header file included by all .c files that need it.
```
int g = 20; //global variable  

int main() {
  int l = 10; //local variable  
}
```