What Is The Difference Between Global Variables And Local Variable?
Answer»
First, Global variables are the variables which can be ACCESSED from anywhere through out the program whereas local variables are those which can only be accessed within the block of code in which they are created.
Second, global variables are visible throughout the program whereas local variables are not KNOWN to the other functions in the programs i.e. they are visible within the block of code in which they are created.
Third, global variables are ALLOCATED memory on DATA Segament whereas local variables are allocated memory on the stack.