Scope in a programming language is the block or a region where a defined variable will have its existence and beyond that region, the variable is automatically destroyed. Every variable has its defined scope. In simple terms, the scope of a variable is equal to its life in the program. The variable can be declared in three places These are:
- Local Variables: Inside a given function or a block
- Global Variables: Out of all functions globally inside the program.
- Formal Parameters: In-function parameters only.