Functions : Scope of a variable

Scope of a variable :

It means till what extent we can access the variable in the program.

There are 3 types of scope of a variable  namely

1, Local
2. Global
3. Static

Local variable
          Variables declared inside the block or function are called as Local Variable. These are created when the function/block execution starts and removed from the memory when the function or block execution completes. If function is executed once again then a fresh copy local variable will be created. These are used to create temporary variables like in Swap() function temp variable is used. It can be accessed only within the function or block in which it is declared.  Any other function can't access local variables.
                                                                                    Continued...

Comments