Unit 4 Programming Exercises

552 Words3 Pages
UNIT 4 Short Answer 1 - 7 Pg. 111 1. How do modules help you to reuse code in a program? A module may be written once and then executed any time it is needed. 2. Name and describe the two parts that a module definition has in most languages. The two parts are a header and a body. Header indicates starting point, and the body is a list of statements. 3. When a module is executing, what happens when the end of the module is reached? It’s executed and returned back to the point in main program where it was sidetracked from. 4. What is a local variable? What statements are able to access a local variable? A variable declared inside a local module, only statement within a module 5. In most languages, where does a local variable`s scope begin and end? Begins at the variables declaration within a module 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? By value only a copy of the argument’s value is passed. By reference its passed into a special modification parameter. 7. Why do global variables make a program difficult to debug? Global variables make a program difficult to debug because any statement in a program file can change the value of a global variable. If you find that the wrong value is being stored in a global variable, you have to track down every statement that accesses it to determine where the bad value is coming from. Algorithm Workbench Review Questions: 1, 5,6, and 7 pg. 111 1. Design a module named timeTen. The module should accept an interger argument. When the module is called, it should display the product of its argument multiplied times 10. Module main() timesTen() Module timesTen Dim Result As Integer Set result = value * 10

More about Unit 4 Programming Exercises

Open Document