Pt1420.U4.A1 Essay

560 Words3 Pages
PT1420 Unit 4, Assignment 1: (Homework) Due: April 18, 2014 Submitted: April 25, 2014 Assignment 4.1, Chapter 3: Modules Short Answer 1. How do modules help you to reuse code in a program? A module may be written once and then executed any time it is needed. 2. Name and describe the two parts that a module definition has in most languages. In most languages, a module definition has two parts: a header and a body. The header indicates the starting point of the module, and the body is a list of statements that belong to the module. 3. When a module is executing, what happens when the end of the module is reached? When a function is executing, it returns when the end of the block is reached, meaning the interpreter jumps back to the part of the program that called the function and the program resumes execution at that point. 4. What is a local variable? What statements are able to access a local variable? A local variable is a variable that is declared inside of a function. Only statements in the same function can access a local variable. 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 its passed into a special modification parameter. 7. Why do global variables make a program difficult to debug? Global variables make a program difficult to debug because any statement in a program file can change the value of a global variable. If you find that the wrong value is being stored in a global variable, you have to track down every statement that accesses it to determine where the bad value is coming from. Algorithm Workbench 1. Design a

More about Pt1420.U4.A1 Essay

Open Document