Preview

Unit 4 Homework

Satisfactory Essays
Open Document
Open Document
401 Words
Grammar
Grammar
Plagiarism
Plagiarism
Writing
Writing
Score
Score
Unit 4 Homework
Short Answers
1. 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
1
1. Module timesTen()
2. Call doubleNumber ()
3. End Module
4.
5. Module doubleNumber(Integer value)
6. Declare Integer result
7. Set result = value * 10
8. Display result
9. End Module

5
1. Module getNumber (Integer Ref value)
2. Set value = 0
3. End Module
6
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
1
1. Module KiloConverter ( Integer value)
2. Declare Integer miles
3.

You May Also Find These Documents Helpful