Why should a variable not be declared as a module variable?
Answers
Ques. Why should a variable not be declared as a module variable?
1) It prevents a procedure from being self contained.
2) It makes it easier to document the code.
3) Local variable names can be reused in other procedures.
4) Both a and b.
5) All of the above.
Answer:
The correct option is 5) All of the above.
Explanation:
In a computer programming language, declaring a variable is a statement that specifies the variable name and data type. A declaration informs the compiler of the existence and position of an entity in the programme. You should also initialise a variable when you declare it.
For each module, a module-level variable is specified. All procedures in that module have access to it, but not the rest of the programme.
A variable should not be declared as a module variable because:
- It makes it impossible for a technique to be self-contained.
- It makes documentation of the code much easier.
- The names of local variables can be reused in subsequent operations.
#SPJ2