Scope of variables
We have indicated scope of variables in the example given in a previous section. Variables
need to be given a limited space within which they should be accessible. If a variable is
defined so that it can be accessed from anywhere (global) scope then it can create a problem
as anybody or any program can change its value which is very dangerous.
Figure 1.3: Scope of variables in procedural programming languages
Figure 1.4: Scope of variables in object oriented programming languages