A variable is a labeled location in memory that is used to store values within a computer program. There are two types of variables: local and global.
There are two types of variable
- Variables defined within a function are called local variables, as they are local to that particular function. These variables can only be seen by the function in which they are defined. These variables have local scope.
- Global variables are defined in the main body of the program outside any particular functions. These variables can be seen by any function and are said to have global scope.
Lets take a look at a simple variable