Sr. No.
|
Local Variable
|
Global Variable
|
1
|
Local variables are those variables which are accessible inside the specific function that creates them.
|
Global Variables are those variables that can be accessed by any function comprising the program.
|
2
|
They are normally implemented using a stack.
|
They are implemented by associating memory locations with variable names.
|
3
|
They are recreated each time a function is executed or called.
| |
4
|
The lifetime or scope of a local variable is just within a procedure or a block
| |
5
|
It makes easy debugging and maintenance of applications.
|
In the case of global variables, one cannot be sure in which function it will be modified or when the variable values will be modified.
|
Saturday, 30 March 2013
Difference Between Local and Global Variables
Labels:
Programming
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment