It104 Wk 4 Hw

432 Words2 Pages
Short Answer 1. How do modules help you to reuse code in a program? Modules help by reusing code to perform tasks over again. 2. Name and describe the two parts that a module definition has in most languages. 3. When a module is executing, what happens when the end of the module is reached? The computer goes back to the module that called it. 4. What is a local variable? What statements are able to access a local variable? Local variables are in the function. Any statement that is in the same scope as the local variable 5. In most Languages, where does a local variable’s scope begin and end? Begins where you declared the variable and ends at the end of the module. 6. What is the difference between passing an argument by value and passing it by reference? By value only a copy of the value is passed. By reference it’s passed into a special parameter. 7. Why do global variables make a program difficult to debug? Algorithm Workbench 1. Design a module named timesTen. The module should accept an Integer 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 Console.ReadLine() End Module 5. Design a module named getNumber, Which uses a reference parameter variable to accept an Integer argument. The module should prompt the user to enter a number and then store the input I the reference parameter variable. 6. What will the following pseudocode program display? Module Main() Declare Integer x = 1 Declare real y = 3.4 Display x, “ ”, Y Call changeUs (x, y) Display x, “ ”, y End Module Module changeUs(Integer a, Real b) Set a = 0 Set b = 0 Display a, “ “, b End Module 7. What will the following psudocode program display? Module main() Declare Integer x = 1

More about It104 Wk 4 Hw

Open Document