Solve the following:
1.
The variables declared outside the functions are know as ______ variables.
2.
The variables declared inside the functions are know as ______ variables.
3.
global keyword in used _________ (inside/outside) function.
4.
The value of global variable _______ (can be/cannot be) displayed inside the function.
5.
The value of global variable _______ (can be/cannot be) modified inside the function.
Question:
What is the difference between local variable and global variable
Local Variable | Global Variable |
It is a variables which is declared within a function | It is a variables which is declared outside all the functions or in global scope. |
It cannot be accessed outside the function but only within a function/block of the program. | Is is accessible throughout the program in which it is declared. |