Preview

Unit 4

Satisfactory Essays
Open Document
Open Document
791 Words
Grammar
Grammar
Plagiarism
Plagiarism
Writing
Writing
Score
Score
Unit 4
Unit 4
1.Five advantages of using global variables.
It is accessible to all the modules in a program
You only have to declare it once outside the modules
It is good to use it for constants you want to keep consistent
It simplifies maintenance, avoids duplication of local constants.
It can make a program easier to read in reference to constants.
Five disadvantages of using global variables.
It makes debugging difficult
Any statement in a program can change the value
If modules use global variables it is dependent upon the module and if other modules are presented you have to redesign all over each time
It makes a program hard to understand since it can be modified and have to be aware of all other parts of the program that access it.
2. Global variables are not writing direct into flowcharts
3. Global variables are displayed in psesudocode but not in flowcharts directly
Short Answers
1. How do modules help you to reuse code in a program? It reduces the duplication of 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. A header and a body, Header indicates starting point, and the body is a list of statements.
3. When a module is executing, what happens when the end of the module is reached? It’s executed and returned back to the point in main program where it was sidetracked from.
4. What is a local variable? What statements are able to access a local variable?
A variable declared inside a local module, only statement within a module
5. In most languages, where does a local variable’s scope begin and end?
Begins at the variables declaration within a module 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 only a copy of the argument’s value is passed. By reference it’s passed into a special modification

You May Also Find These Documents Helpful

  • Good Essays

    Declares > this is the statements that declare variables, constants, and other code elements, which can then be used within that block…

    • 193 Words
    • 1 Page
    Good Essays
  • Satisfactory Essays

    If a operation needs to be performed in several places, the same module can be called and re-used cutting down on unnecessary code.…

    • 765 Words
    • 5 Pages
    Satisfactory Essays
  • Satisfactory Essays

    Homework Unit 3

    • 354 Words
    • 2 Pages

    6. In passing argument by value- any changes made to the parameter value won't affect argument outside module. In passing argument by reference- Changes will affect actual argument passed to module.…

    • 354 Words
    • 2 Pages
    Satisfactory Essays
  • Good Essays

    This paper will describe the variable naming rules of three different programming languages. These three languages are Visual Basic, Python, and Java. Each of these languages has different rules that apply to them and some similarities. I will describe the rules and the similarities and differences in the next few paragraphs.…

    • 878 Words
    • 4 Pages
    Good Essays
  • Good Essays

    Yet in an OOP, modules in the form of objects interact by sending messages to other objects. The power of OOP comes from the ability to inherit, encapsulate, and abstract that procedural logic. The importance of OOP is not as much in the language mechanism as it is in the thinking and designing process.…

    • 793 Words
    • 4 Pages
    Good 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
  • Satisfactory Essays

    Unit 4 Homework

    • 401 Words
    • 2 Pages

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

    • 401 Words
    • 2 Pages
    Satisfactory Essays
  • Good Essays

    2. Class objects normally have _____ that perform useful operations on their data, but primitive variables do not.…

    • 1518 Words
    • 7 Pages
    Good Essays
  • Better Essays

    5) A local variable’s scope begins at the variable’s declaration and ends at the end of the module in which the variable is declared.…

    • 1580 Words
    • 11 Pages
    Better Essays
  • Satisfactory Essays

    Lab 7 Student

    • 1242 Words
    • 7 Pages

    Step 1: Examine the following pseudocode main module from Lab 4.1. Loops are commonly used to call modules multiple times. The best design is to use a loop around the module calls in Main.…

    • 1242 Words
    • 7 Pages
    Satisfactory Essays
  • Better Essays

    III. The variables, methods, and classes that are part of the class definition are commonly called class members.…

    • 939 Words
    • 4 Pages
    Better Essays
  • Good Essays

    Unit 4

    • 1432 Words
    • 6 Pages

    I have chosen the Vygotsky theory which is related Cooperative play would take place at home. A child could act out in the role play area this will be a learning opportunity as their will be encouraged to play and talk their friends…

    • 1432 Words
    • 6 Pages
    Good Essays
  • Good Essays

    8. Is it possible that the instructions within a While statement might never be executed at all? Give an example.…

    • 610 Words
    • 3 Pages
    Good Essays
  • Good Essays

    Procedural programming modules and objects are similar in that they use most of the same commands to execute their functions and store their data but also are very different. Procedural modules are easier to use for small specific programs that perform specialized functions. Objects are better used for more general operations that show a need for more complex and reusable functions that may require security and hidden code to avoid any corruption or mistakes. Both options permit private and local variables to be declared but modules can use data separate from the module where an object has its within itself and can be accessed only through its own methods when it is called upon by the program around it.…

    • 767 Words
    • 4 Pages
    Good Essays
  • Good Essays

    Image Processing

    • 974 Words
    • 4 Pages

    1, a parameter is a special kind of variable, used in a subroutine to refer to one of the pieces of data provided as input to the subroutine.[1] These pieces of data are called arguments. An ordered list of parameters is usually included in the definition of a subroutine, so that, each time the subroutine is called, its arguments for that call can be assigned to the corresponding parameters.…

    • 974 Words
    • 4 Pages
    Good Essays