Friday, May 16, 2008

Scope of variables: LOcal and Global

Scope of variables: LOcal & Global

Scope of variable means where the variable stands in the program. All variables may not necessary be available to all statements in a program.

Variables can have two types of scope:

a) Local:

When a variable is declared inside the function then such a variable is known as local variable.

A local variable can only be accessed by the function in which it is declared. It cannot be accessed by other function.

b) Global:

A variable which is declared outside all functions is known as global variable.

A variable with a global scope is accessible to all the statements in the program. A global variable can be accessed by all the functions.

0 comments:

Copyright

Copyright © 2008 C Tutorial, All rights are reserved