How do modules help you to reuse code in a program? Performs the task once then reuses it each time you need to perform the task. 2.
Name and describe the two parts that a module definition had in most languages. Header and Body 3.
When the module is executing, what happens when the end of the module is reached? Computer jumps back to the part of the program that called the module 4.
What is a local variable? What statements are able to access a local variable? A variable that is declared inside a module. Only statements inside the module can access the variable. 5.
In most languages, where does a local variable’s scope begin and end? A local variable’s scope usually begins at the variable’s 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? By Value means that only a copy of the argument’s value is passed into the parameter variable. Passing by Reference means that the argument is passed into a special type of parameter. 7.
Why do global variables make a program difficult to debug? You’ll have to track down every statement that accesses it to determine where the bad value is coming from. Algorithm
Call doubleNumber ()
Module doubleNumber(Integer value)
Declare Integer result
Set result = value * 10
Module getNumber (Integer Ref value)
Set value = 0
Not Sure what is going to happen because I wrote that whole program and nothing happen. The Value is passed into the parameter value on this program module though. 7
Same with this one actually wrote it to see and nothing happen. The argument is passed into a special type of parameter on this program module. Programming Exercise
Module KiloConverter ( Integer value)
Declare Integer miles
Please join StudyMode to read the full document