C
Programming and Technical
Programming
Definition
Diffrence Between Global & Extern Variable?
Read Solution (Total 6)
-
- We need not to initialize global variables... it ll take a garbage value if we dont initialize...
In case of extern variables, we need to initialize...
Global variables can be declared above the main function ,so that can be accessed from within the same program and a program from another file...
Extern variables can be declared above main function (can be accessed by another program too) and inside the main function too (can be accessed from within the program only)... - 10 years agoHelpfull: Yes(28) No(3)
- Global variables can be declared above the main( ) function. These variables are accessible throughout the program. They can be accessed by all the functions in the program. Their default value is zero.
Extern variables can be declared above the main function. It's default value is zero. It's scope is global and life time of a extern variable is as long as the program execution doesn't come to an end. - 10 years agoHelpfull: Yes(2) No(0)
- I thing,global variable is declared above the program.That can be access by whole program and extern variable is local variable that is in the method of the program.
- 10 years agoHelpfull: Yes(0) No(2)
- Extern variable are accessed from other program...and Global variable are define d before the main() function
- 10 years agoHelpfull: Yes(0) No(0)
- The basic difference between global and extern variable is "for Global we dont need to initialize these variable" and "in case of extern variable initialization is necessary"
- 10 years agoHelpfull: Yes(0) No(0)
- Global variable:These are the variables which are declared above main so that all the functions can access these variables i.e., its scope is through out the program.
Extern Variable:Extern keyword is used when we want to access the variable from another program.
- 10 years agoHelpfull: Yes(0) No(0)
C Other Question