GlobalAndLocal Program
Description
This program demonstrates the difference between global and local variables.Associated Concepts:
Variable scope: global and local variables
Algorithm:
Declare a global variable x and initialize it
to certain value
main method:
Write three method definitions
main method:
Declare a local variable x and initialize it
to another value
Change the value of the local variable x
Print both the local and global variables x
Call three methods which are supposed to modify the value of the global variable x
Print both the local and global variables x
Change the value of the local variable x
Print both the local and global variables x
Call three methods which are supposed to modify the value of the global variable x
Print both the local and global variables x
Write three method definitions
Modify the value of the global variable x