Preview

unit 4

Satisfactory Essays
Open Document
Open Document
691 Words
Grammar
Grammar
Plagiarism
Plagiarism
Writing
Writing
Score
Score
unit 4
Unit 4 Assignment 1: Homework
Short Answer
1. How do modules help you to reuse code in a program?
It reduces the duplication of a code within a program by reusing the module that was written once.
2. Name and describe the two parts that a module definition has in most languages.
The Header and a Body
First the Header indicates a starting point
Second the Body is a list of statements
3. When a module is executing, what happens when the end of the module is reached?
Its executed and returned back to the point in the main program where it was sidetracked from
4. What is a local variable? What statements are able to access a local variable?
A variable is declared inside a local module in which it is the only statement within a module
5. In most languages, where does a local variable’s scope begin and end?
It begins at the variables declaration within a module and it 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 the value only a copy of the arguments value is passed and by reference it is passed into a special modifications parameter.
7. Why do global variables make a program difficult to debug?
It is because the global variables is used throughout all modules and plus they are hard to track.

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 ()
Call timesTen
Module timesTen (Integer Value)
Declare integerValue
Set result = value*10
Display result
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 in the reference parameter variable.

Module getNumber (Integer Ref value)
Display “Display a number”
Input number
End

You May Also Find These Documents Helpful

  • Good Essays

    Nt1310 Unit 5 Lab Report

    • 490 Words
    • 2 Pages

    ERROR AND DEBUGGING: Once the simulation has started it checks for the errors in the ladder diagram, address etc. if there is an error, the output cannot be processed until the error is rectified.…

    • 490 Words
    • 2 Pages
    Good Essays
  • Satisfactory Essays

    Unit 4

    • 474 Words
    • 2 Pages

    My comparisons are based on the surveys provided in the simulation. Tim’s seems to be offering a fair product but will need to compete with a chain coffee shop. This means he will have to offer exceptional service and value to his product. He needs to set himself apart from the standard chain store. He can achieve this by ensuring a wide variety of great products. Most importantly the service will make or break any retail establishment. Having great service and satisfied customers will keep them returning. The fact that he has an ideal location is a good start. Adding conveniences like debit card capability and wi-fi will only increase business.…

    • 474 Words
    • 2 Pages
    Satisfactory Essays
  • Satisfactory Essays

    Unit 4 Homework

    • 401 Words
    • 2 Pages

    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.…

    • 401 Words
    • 2 Pages
    Satisfactory Essays
  • Satisfactory Essays

    Unit 4

    • 359 Words
    • 1 Page

    1. What is the term used to describe a read-only copy of a user profile stored on a network share? Mandatory Profile.…

    • 359 Words
    • 1 Page
    Satisfactory Essays
  • Better Essays

    6) When you pass by value you pass a copy. When you pass by reference, you can modify the contents.…

    • 1580 Words
    • 11 Pages
    Better Essays
  • Better Essays

    ii. The optional keyword static is used to declare a special kind of variable called a class variable. Class variables will be discussed in another lecture.…

    • 939 Words
    • 4 Pages
    Better Essays
  • Good Essays

    It-250 Week 5 Questions

    • 397 Words
    • 2 Pages

    1. What function does every C program have? Why should you split large programs into several functions?…

    • 397 Words
    • 2 Pages
    Good Essays
  • Satisfactory Essays

    Reusability of Code

    • 486 Words
    • 2 Pages

    Designing a code can often take a lot of time, depending on the complexity of the coding. This is why code reusability has become a standard when it comes to computer programming. But to understand why you would reuse code, you need to understand what goes into creating code. This essay will compare and contrast procedural programming modules and objects. Also, it discuss the security terms in hiding code, passing of data versus data encapsulation, code reuse in more than one program, and how object-oriented methods are similar to procedural modules.…

    • 486 Words
    • 2 Pages
    Satisfactory Essays
  • Satisfactory Essays

    another person is restricted to the object’s method, this way the program is protected from any…

    • 584 Words
    • 3 Pages
    Satisfactory Essays
  • Satisfactory Essays

    How Oracle Works

    • 354 Words
    • 2 Pages

    1. Throughout this entire procedure, the other background processes run, watching for conditions that require…

    • 354 Words
    • 2 Pages
    Satisfactory Essays
  • Good Essays

    used to avoid errors that imply having to reproduce over again. It is indeed costly…

    • 1194 Words
    • 5 Pages
    Good Essays
  • Good Essays

    java virtual machine

    • 731 Words
    • 3 Pages

    The execution environment section is used to maintain the operations of the stack itself. It is pointed to by the frame register.…

    • 731 Words
    • 3 Pages
    Good Essays
  • Satisfactory Essays

    why oky

    • 304 Words
    • 5 Pages

    Which of the following is NOT an advantage of CSS defined for the entire site?…

    • 304 Words
    • 5 Pages
    Satisfactory Essays
  • Good Essays

    Top Tech Trends of 2012

    • 511 Words
    • 4 Pages

    a.) Draw a DFA that accepts all strings in (a + b)* that do not contain bababb as a substring…

    • 511 Words
    • 4 Pages
    Good Essays
  • Good Essays

    © Differentiate between call by value or pass by value and call by reference or pass by reference [2]…

    • 1978 Words
    • 8 Pages
    Good Essays