- Programs are made up of functions (one of them has to be main)
|
|
- To make programs easier to understand
- To avoid repetitive coding
- Variables declared inside a function are called local variables
- These variables are only known to main() (they are only known to the function)
- Local variables occupy memory space only when the function is called
- In general, variables declared inside a block are called local variables
- These variables are valid only inside the block they have been declared
- Variables declared outside any function are called global variables
- Global variables are known to any function !!