Friday, 25 January 2013

Scope of the variable V/S Life of the variable

Q. What is meaning of scope of the variable and life of the variable?
Explain with example.

Ans.

scope of the variable

The range of code in program over which a variable has a meaning is called a scope of the variable.

In other words, the scope of variable decides as to how it can be accessed by the different parts of the program.

Following are the types of scopes:

  1. Local scope
  2. Global scope
  3. Function scope
Life of the variable

Life of the variable means how long would the variable exist.


Related Article:

No comments:

Post a Comment