What do you understand by scope of a variable ?


Scope of a variable means availability of a variable. The variable can be accessed only within the function where it is declared. Global variables are accessible within all functions. A variable defined within a function is not visible in other functions. If local variable and global variable have same name, then within the function, if the name is used, then the value of local variable is accessed. That is local variable overrides the global variable.

Post a Comment

0 Comments