1. If the variable is declared at the beginning of the file, it is visible everywhere (inside all functions) that is, it is a global variable.
Example...
2. If a variable is declared inside a function, it is visible only within that function.
Example...
3. If the variable is declared at the beginning of the file and the same variable is declared inside the function, then the variable inside the function DOES NOT affect the variable at the beginning of the file (these are different variables).
Example...
4. If a variable is declared anywhere and the same variable is declared just below inside block then variable inside block AFFECTS the variable above (it's the same variable).
Example...