***Welcome to ashrafedu.blogspot.com * * * This website is maintained by ASHRAF***

Saturday, July 24, 2021

Local Variables

A
local variable belongs to the function in which it is created, and only
statements inside that function can access the variable. An error will occur if
a statement in one function tries to access a local variable that belongs to
another function.


A
variable’s scope is the part of a program in which the variable may be
accessed. A variable is visible only to statements in the variable’s scope. A
local variable’s scope is the function in which the variable is created. A
local variable cannot be accessed by code that appears inside the function at a
point before the variable has been created. Because a function’s local
variables are hidden from other functions, the other functions may have their
own local variables with the same name.



No comments:

Post a Comment