Quiz5-Modules Flashcards

1
Q

Modules make it impossible for programmers to work in teams: (T/F)

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

The “Top-Down” design process is sometimes referred to as “Stepwise Refinement.” (T/F)

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

A module can have two or more variables with the SAME name because they are within the same scope. (T/F)

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

The scope of a variable is the segment of the program in which the variable can be accessed. (T/F)

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

The arguments in a module call and the parameters listed in the module header must be of a compatible data type. (T/F)

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

The scope of the parameter variables is the entire program and they are visible to any statement in the program. (T/F)

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

When a variable is passed by value, changes to that argument made within the module also affect the value of the variable in the part of the program that made the call to that module.(T/F)

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

A hierarchy chart does not reveal details of the steps taken inside the module.(T/F)

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

When a variable is passed by reference to a module, changes to the value of the argument in the module will also affect the variable in the part of the program that sent that argument.(T/F)

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

An attempt to pass a non-variable argument into a reference variable parameter will cause an error.(T/F)

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Modules can be written for commonly needed tasks, and those modules can be incorporated into each program that needs them.(T/F)

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

In most languages, a module definition has three parts: a header, body, & footer.(T/F)

A

False: (header & body)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Which of the following is NOT a benefit of using modules when developing a program?

A) They make program development faster

B) Module code can be reused

C) They make Programs easier to debug

D) Programs which contain modules always run faster than programs without modules

A

D) Programs which contain modules always run faster than programs without modules: not necessarily true while A,B,C are always true

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

A module definition consists of the module header and the module….

A

Body

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

In a flowchart, a module call is repersented by a(n)__________ symbol with vertical bars at each side.

A

Rectangle

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What would a programmer use to visualize the relationship between modules?

A

a hierarchy chart

17
Q

A _________ is a variable that RECIEVES AN ARGUMENT which is passed to a module

A

parameter

18
Q

When an argument is passed by ________, only a COPY of the argument’s VALUE is passed into the parameter variable.

A

value

19
Q

When an argument is passed by __________, the parameter receives the address of the argument so BOTH THE ARGUMENT AND THE PARAMETER point to the same memory location.

A

reference

20
Q

A _______ variable is visible to every module AND the entire program.

A

global

21
Q

the use of ___________ variables MAY make programs hard to understand and debug.

A

global

22
Q

An argument that is passed by _________ is NOT affected by a change to the content of the parameter variable.

A

value: (bc its a copy i’m assuming)

23
Q

Another name for a module is a(n)__________.

A

function

24
Q

Modules may also be called…..

A) Procedures
B) Subroutines
C) Subprograms
D) Methods
E) None of These
F) Any of These

A

F) Any of These:
Procedures, subroutines, subprograms, and methods

25
Q

To create a module, you write its ______________.

A

definition: a module definition is a statement “Define” or “def” and “Call” in pseudocode

26
Q

To execute a module, you must ___________.

A

Call it

27
Q

The __________ is the first line of a module definition.

A

header

28
Q

Given the following pseudocode, which is the argument?

Module main()
Call curveScore(82)
End Module
Module curveScore(Integer score)
Declare Integer newScore
Set newScore= score + 5
Display newScore
End Module

A

82: bc arguments are always passed as a variable thru the call

29
Q

Given the following pseudocode, which is the parameter?

Module main()
Call curveScore(82)
End Module
Module curveScore(Integer score)
Declare Integer newScore
Set newScore= score + 5
Display newScore
End Module

A

score: bc module curvescore is being defined using a variable named score

30
Q

Given the following pseudocode, what is the value of myGrade after the call to the curveScore module?

Module main()
Declare Integer myGrade
Set myGrade = 82
Call curveScore(myGrade)
End Module
Module curveScore(Integer score)
Declare Integer newScore
Set newScore= score + 5
Display newScore
End Module

A

82

31
Q

Given the following pseudocode, what is the value of the score after the call to the curveScore module?

Module main()
Declare Integer myGrade
Set myGrade = 82
Call curveScore(myGrade)
End Module
Module curveScore(Integer score)
Declare Integer newScore
Set newScore= score + 5
Display newScore
End Module

A

82

32
Q

Given the following pseudocode, what is the value of score after the call to the curveScore module?

Module main()
Declare Integer myGrade
Set myGrade = 82
Call curveScore(myGrade)
End Module
Module curveScore(Integer score)
Declare Integer newScore
Set newScore= score + 5
Display newScore
Set score = 0
End Module

A

0

33
Q

Given the following pseudocode, what if anything, as an error?

Module main()
Declare Integer myGrade = 93
Call curveScore(myGrade)
End Module
Module curveScore(Integer score)
Declare Integer newScore
Set newScore = score + 5
Display newScore
Set myGrade = 0
End Module

A) The variable score has not been intialized

B) The variable myGrade is not available inside the curveScore module

C) The curveScore module should recieve a variable named score, not MyGrade

D) There are no errors

A

B) The variable myGrade is not available inside the curveScore module