What are the difference between global and local variables?
Global Variable
|
Local Variable
|
Global
Variable is variable which is declared before main function.
|
Local
Variable is variable which is declared inside the main function or other
functions.
|
A global variable can be accessed by all functions.
|
A local variable is isolated in its function.
|
It’s working
with changing values.
|
It’s not
working with changing values.
|
Variables
treat(use) only one name in program.
|
Same
variable names are working different values in different functions.
|
They are known to other functions and to the main program.
|
They are unknown to other functions and to the main program.
|