PT1240 Unit 3 Assignment 1
Short Answer Questions 1. How do modules help you to reuse code in a program?
It reduces the duplication of code within a program, and it can be executed at any time when it’s needed.
2. Name and describe the two parts that a module definition has in most languages.
A header and a body.
3. When a module is executing, what happens when the end of the module is reached?
It jumps back to the return point and resumes execution.
4. What is a local variable? What statements are able to access a local variable?
A local variable is a variable that is declared inside a module. Programmers commonly use the term scope to describe the part of a program in which a variable may be accessed
5. In most languages, where does a local variable’s scope begin and end?
A variable’s scope begins at the declaration, and ends at the end of the module in which the variable is declared.
6. What is the difference between passing an argument by value and passing it by reference?
To pass an argument by value means that only a copy of the arguments’ value is passed into the parameter variable, while an argument by reference means that the argument is passed into a special type of parameter known as a reference variable.
7. Why do global variables make a program difficult to debug?
Because any statement in a program can change the value of a global