See related link.
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.
global
It's a global variable.
Global Varible: The variable which is declared as "Global" one : having the preveleges to use and access that variable in any class and object( means any where in the program) just like PUBLIC keyword in OOPS concepts. Static Variable : If we declare a variable as Static , then it wont have the permission to access that variable through out the program and u have to use it inside the class or object which u declared itself. All the Best Annapurna
global and static
Variables that are declared globally outside every program are called global variables.
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 variable that is defined within a block is considered to have local scope, i.e., it is only visible to the block that contains it. Its lifetime is also limited unless it is marked as a 'static' variable, in which case it will exist for the entire length of program execution.
When you acess a global variable inside main function you must use the same name, because the variable declared as global can be accessed by any function/procedure on the class where it was defined.
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
The part of a program in which a particular variable may be accessed is called the 'scope' of the variable. In most cases, the scope of a variable is limited to the function within which it was created, or any function it is passed to as an argument. You can also use global variables, which can be accessed from any part of the program and have 'global scope'. However, this is generally considered as poor programming practice, and should be used cautiously and sparingly as it tends to make code difficult to read and maintain.