Tamil Nadu Board of Secondary EducationHSC Science Class 12th

Define Local scope with an example. - Computer Science

Advertisement Remove all ads
Advertisement Remove all ads
Advertisement Remove all ads
Short Note

Define Local scope with an example.

Advertisement Remove all ads

Solution

Local Scope:

Local scope refers to variables defined in the current function. Always, a function will the first lookup for a variable name in its local scope. Only if it does not find it there, the outer scopes are checked.

Look at this example

On execution of the above code, the variable a displays the value 7, because it is defined and available in the local scope.

Concept: Types of Variable Scope
  Is there an error in this question or solution?

APPEARS IN

Share
Notifications

View all notifications


      Forgot password?
View in app×