Unit 4 Homework

Topics: Perl, Ring, Local variable Pages: 2 (401 words) Published: October 27, 2014
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. Module timesTen()
2. Call doubleNumber ()
3.End Module
5.Module doubleNumber(Integer value)
6. Declare Integer result
7. Set result = value * 10
8. Display result
9.End Module

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

Please join StudyMode to read the full document

You May Also Find These Documents Helpful

  • unit 4 Essay
  • Essay about Unit 4
  • PT1420 Unit 4 Assignment 1 Homework Essay
  • homework Essay
  • D1 unit 4 Essay
  • MAT 540 Week 4 Homework Essay
  • Homework Unit 3 Essay
  • Essay about KaitlynTipton Homework Unit 4

Become a StudyMode Member

Sign Up - It's Free