The difference between Local and Global variables are below;
a. Global variables are declared outside the function, and they can be used on any function in the program while Local variables are declared only within a function. It is likely to have local variables with an identical name in various functions. Even the name is identical; they are not the same. It's similar to two individuals having the same name. Even the name is the same; the individuals are not.
b. Parameters passing is not needed for a global variable while it is required for local variables
c. The global variable offers data sharing, while the local variable does not provide data sharing.
d. Global variable is built as execution begins and is lost when the program stops, whereas local variables are created when the function has begun execution and is lost when the function ends
e. Global variables are kept on a permanent position decided by the compiler while local variables are stored on the stack.