There are two ways to declare varibles.
1. Locally
2. Globally When you declare a variable locally in any function that means it is only accessible by that function. When you declare a variable globally so it is accessible by all the functions in the program. Declaring variables with static keyword means you are setting its value null.
The accessibility. The global one: almost everywhere in the code may reference to the global variable directly. The private variable, is private to the declaring module (class, method, assembly) only. Outside of that module has no access to it directly.
Their scope.
static variable is available to the module where it is defined. Global variable is available through out the pgm
When you say static variable, do you mean local static variable or global static variable? In C, the difference between global static variables and global variables is that static in this case means that the variable can be used only in the module (.c file) that it is declared. The difference between a local static variable and a global variable is the scope: the local variable can be used only inside the function that declares it. So you can have 2 local static variables in the same file with the same name but in different functions and they will be 2 different variables.
A static variable is a variable allocated in static storage. A local variable is a variable declared inside a function. A global variable is a variable declared outside of any class or function. Note that local variables and global variables can both be allocated in static storage.
Global variables are system-wide variables set by the OS at start-up, and can't be modified. Environmental variables are variables that are system-wide, but can be modified.
In C programming, a static variable declared outside of any function is global, but local to the current module. A static variable declared within a function retains its value between function calls.
extern variables are defined in different than the file where the main() is. extern variables can be accessed from other files. Static global variables are visible only within the file.
Global (file scope) variable and static global variables both retain their value for the duration of the program's execution. Static global variables are visible only to functions within the file they are declared, while global variables are visible to all compilation units (files) within the linked load module.
the difference between global and international strategy
what is the difference between international communication and global communication
4m Sai. Gloabal Variable is variable which is declared before main (). int a=10; main() { } here a is a global variable. where ever u r using this variable ... we'll get the value as 10. Local Variable is a variable which is declared inside the main(). int a=10; main() { int a=5; ........ ....... } here a=5 is a local variable and a=10 is called as global variable. then if u want to get a value... printf("%d",a); then result 'll be a=5; B'cos compiler gives main preference to local variables.. if any local declareation is not there then it 'll prefer global variable.