1.In computer programming, a global variable is a variable that is accessible
in every scope.
2.There are some variables that are used in more than one function.such
variables are called global variables.
3.Usually,they are declared in global declaration section that is outside
of all functions.
4.In this section,we can also declare all user-defined functions.
DECLARATION:
int global =5;
global
It's a global variable.
See related link.
global and static
Variables that are declared globally outside every program are called global variables.
Program enter function.
A global declaration of a function or variable is a declaration that is at the global scope of the program, not inside another function. This means that the name will be visible within all functions in the program.
Your program won't work correctly.
A global variable is available for use throughout the program. It is normally declared outside any procedure. A local variable is only available for use in the procedure it was declared in. Most variables are local, but there will be occasions when you want different procedures to be able to use the same variable. This is when you use a global variable.
If you are talking about a class in Java, a variable encapsulated by a class is called an instance variable b/c everytime you create an object with that class, each object has its own set of the variables declared.
Scope of static variable is with in the file if it is static global. Scope of static variable is with in the function if variable is declared local to a function. But the life time is throughout the program
True, a variable cannot be both global and local. But if a global and a local variable share the same name, the local one will hide the global.