Program Modules, Subprograms, and Ch.9 Complete Test Bank 6e - Practice Test Bank | Prelude Programming 6e Venit by Stewart Venit. DOCX document preview.

Program Modules, Subprograms, and Ch.9 Complete Test Bank 6e

Test Bank for Prelude to Programming Chapter 9

MULTIPLE CHOICE

1. Using arguments and corresponding parameters to pass data among program modules is an important feature of modular programming because:

a.

it enhances the usefulness of subprograms

b.

it makes it easier for different programmers to design and code different subprograms

c.

it makes it easier to test and debug a subprogram independently of the main program

d.

all of the above are true

2. Given the following two program statements, identify the parameters.

Call DressUp(sandals, turtleneck, jeans)

Subprogram DressUp(shoes, shirt, pants)

a.

sandals, turtleneck, jeans

b.

shoes, shirt, pants

c.

DressUp(shoes, shirt, pants)

d.

sandals, turtleneck, jeans, shoes, shirt, pants

3. Given the following two program statements, identify the arguments.

Call DressUp(sandals, turtleneck, jeans)

Subprogram DressUp(shoes, shirt, pants)

a.

sandals, turtleneck, jeans

b.

shoes, shirt, pants

c.

DressUp(shoes, shirt, pants)

d.

sandals, turtleneck, jeans, shoes, shirt, pants

4. Given the following statements, what values will be passed to the parameters (sandwich, side, and drink) of the subprogram named Lunch?

Call Lunch(soda, chips, burger)

Subprogram Lunch(sandwich, side, drink)

a.

sandwich = soda, side = burger, drink = chips

b.

sandwich = soda, side = chips, drink = burger

c.

sandwich = burger, side = chips, drink = soda

d.

Lunch = burger with chips and a soda

5. Given the following statements, what values will be passed to the parameters of the subprogram named Vacation?

Declare Motel As String

Declare Interstate As Integer

Set Motel = “Dew Drop Inn”

Set Interstate = 95

Call Vacation(Motel, Interstate)

Subprogram Vacation(String Lodging, String Road)

a.

Lodging = “Dew Drop Inn”, Road = “95”

b.

Lodging = “Dew Drop Inn”, Road = 95

c.

Lodging = Motel, Road = Interstate

d.

This cannot be done, type mismatch

6. What is displayed after code corresponding to the following pseudocode is run?

Set X = 15

Set Y = 25

Set Z = 20

Call Numbers(Z, Y, X)

Subprogram Numbers(A, B, C)

Write A + “ “ + B + “ “ + C

End Subprogram

a.

15 25 20

b.

15 20 25

c.

20 25 15

d.

25 20 15

7. What is displayed after code corresponding to the following pseudocode is run?

Set X = 15

Set Y = 25

Set Z = 20

Call Numbers(X, Z, Y)

Subprogram Numbers(A, B, C)

Write A + “ “ + B + “ “ + C

End Subprogram

a.

15 25 20

b.

15 20 25

c.

20 25 15

d.

25 20 15

8. What is displayed after code corresponding to the following pseudocode is run?

Set X = 15

Set Y = 25

Set Z = 20

Call Numbers(Y, Z, X)

Subprogram Numbers(A, B, C)

Write A + “ “ + B + “ “ + C

End Subprogram

a.

15 25 20

b.

15 20 25

c.

20 25 15

d.

25 20 15

9. What will be displayed after code corresponding to the following pseudocode is run?

Main

Set OldPrice = 100

Set SalePrice = 70

Call BigSale(OldPrice, SalePrice)

Write “A jacket that originally costs $ “ + OldPrice

Write “is on sale today for $ “ + SalePrice

End Program

Subprogram BigSale(Cost, Sale As Ref)

Set Sale = Cost * .80

Set Cost = Cost + 20

End Subprogram

a.

A jacket that originally costs $100

is on sale today for $80

b.

A jacket that originally costs $100

is on sale today for $70

c.

A jacket that originally costs $120

is on sale today for $80

d.

A jacket that originally costs $120

is on sale today for $70

10. What is wrong with the following program segment?

Main

Declare Apples As Integer

Set Apples = 4

Call Snack(Apples)

Write “You have “ + Apples + “ apples”

Write “and “ + Oranges + “ oranges”

End Program

Subprogram Snack(Fruit)

Declare Oranges As Integer

Set Oranges = Fruit + 2

End Subprogram

a.

you cannot call a subprogram that has only one parameter

b.

you cannot declare variables within a subprogram

c.

you cannot access a variable that has been declared locally within a subprogram outside that subprogram

d.

nothing is wrong with the code segment

11. What will be displayed after code corresponding to the following pseudocode is run?

Declare Word As String

Declare Count As Integer

Set Word = “Bunny”

Set Count = 1

While Count < 5

If Floor(Count/2) == Count/2 Then

Set Word = ToUpper(Word)

Else

Set Word = ToLower(Word)

End If

Write Word

End While

a.

BUNNY

BUNNY

BUNNY

BUNNY

BUNNY

b.

BUNNY

bunny

BUNNY

bunny

BUNNY

c.

bunny

BUNNY

bunny

BUNNY

d.

bunny

BUNNY

bunny

12. What will be displayed after code corresponding to the following pseudocode is run?

Main

Declare A As Float

Declare B As Float

Set A = 4

Set B = 20

Call Math(A, B)

Write B + “ divided by “ + A + “ = “ + B/A

End Program

Subprogram Math(Float Num1 As Ref, Float Num2)

Set Num1 = 5

Set Num2 = 25

End Subprogram

a.

20 divided by 4 = 5

b.

20 divided by 5 = 4

c.

25 divided by 5 = 5

d.

25 divided by 4 = 6.25

13. What is the value of X in the following expression?

Set X = Str(-685.23)

a.

685

b.

-685

c.

“-685.23”

d.

“685.23”

14. What is the value of X in the following expression, given that Y = 429:

Set X = Round(Y/8)

a.

53

b.

53.75

c.

54

d.

this cannot be done

15. Given the following pseudocode, identify the line of code that is recursive.

1 Function Sum(N) As Integer

2 If N = 1 Then

3 Set Sum = 1

4 Else

5 Set Sum = Sum(N–1) + N

6 End If

7 End Function

a.

Line 1

b.

Line 2

c.

Line 3

d.

Line 5

e.

Line 7

16. A Call statement that passes values to a subprogram contains the subprogram’s name and, in parentheses, a list of:

a.

parameters

b.

arguments

c.

variables

d.

any of the above

17. The part of a program in which a given variable can be referenced is that variable’s:

a.

value

b.

scope

c.

name

d.

argument

18. Given the following program segment, what data is passed from the Main program to the subprogram named Display?

Main

Declare R As Integer

Set R = 2

Call Display(R*6, R+1, 14)

End Program

Subprogram Display(X, Y, Z)

Write X + “, “ + Z + “, “ + Y

End Subprogram

a.

2, 2, 14

b.

12, 3, 14

c.

12, 14, 3

d.

this cannot be done

19. Given the following function:

Function AddIt(X) As Float

Set AddIt = X + 15/2

End Function

What is displayed when the following statement in the main program is executed?

Write AddIt(4)

a.

9.5

b.

9

c.

11.5

d.

11

20. Given the following function:

Function DivideIt(X) As Float

Set DivideIt = Int(X/2)

End Function

What is displayed when the following statement in the main program is executed?

Write DivideIt(9)

a.

4

b.

4.5

c.

5

d.

5.0

19. Given the following function:

Function Power(K, M) As Float

Set Power = M^K

End Function

What is displayed when the following statement in the main program is executed?

Write Power(3, 4)

a.

27

b.

256

c.

64

d.

81

TRUE/FALSE

1. True/False: If a data item which is processed by a subprogram is needed by the main program, its value is imported to the main module.

2. True/False: A subprogram must always return a value to the program or subprogram that calls it.

3. True/False: A data flow diagram shows the data imported by and exported from each program module.

4. True/False: The items listed in parentheses in a Call statement are known as arguments.

5. True/False: Parameters, as well as arguments, can be constants, variables, or general expressions.

6. True/False: Changes to the value of value parameters do not affect the value of the corresponding variables in the calling module.

  1. True/False: When a variable is passed by value, the submodule that variable is passed to will receive the actual storage location where the value of the variable is stored.

8. True/False: The Round(X) function and the Int(X) function do exactly the same thing.

9. True/False: Functions that are program modules, created by the programmer, are called built-in functions.

10. True/False: Code for built-in functions is supplied by the programming language in separate modules, often referred to as a library.

  1. True/False: A function’s name may be assigned a value in the code that defines it.

12. True/False: The value of Int(-35.8) is 35.

13. True/False: To solve the problem of how to code a repeated multiplication problem, recursion must be used.

14. True/False: Since Abs(-5) = 5 and Int(5.3) = 5, these two functions can be used interchangeably.

15. True/False: A built-in function is called by using the function name anywhere in a program where a constant of that type is allowed.

SHORT ANSWER

1. If data in the main program is needed by a subprogram, the value of that data is passed to, or __________ by, the subprogram.

2. A(n) __________ __________ diagram can be used to keep track of the data passed among the various modules.

  1. The ToUpper() function converts all characters in a string to __________ .
  2. The items appearing in a subprogram header are known as __________.

5. When a subprogram is called, the values of the __________ are assigned to corresponding __________.

6. The string “6.9” is stored in memory by placing the ASCII codes for “6”, “.”, and “9” in __________ storage locations.

7. When a variable is passed by __________ to a submodule, that submodule receives only a copy of that variable.

8. A variable that is declared outside all program modules, including the main module, has __________ scope.

9. Programming languages usually supply an assortment of __________ functions

10. The function that converts the string “YES” or “Yes” to “yes” is __________.

11. When a program or subprogram calls itself, this process is known as __________.

12. The function that converts a number, X, to a corresponding string is the __________ function.

13. Programming languages allow the programmer to create his or her own functions which are called __________ __________ functions.

14. If a variable is declared both locally and globally, it is treated as if it were two different variables, and the __________ declaration takes precedence.

15. The number and type of arguments in a Call statement must be the same as the __________ and __________ of parameters in the corresponding subprogram header.

Document Information

Document Type:
DOCX
Chapter Number:
9
Created Date:
Aug 21, 2025
Chapter Name:
Chapter 9 Program Modules, Subprograms, and Functions
Author:
Stewart Venit

Connected Book

Practice Test Bank | Prelude Programming 6e Venit

By Stewart Venit

Test Bank General
View Product →

$24.99

100% satisfaction guarantee

Buy Full Test Bank

Benefits

Immediately available after payment
Answers are available after payment
ZIP file includes all related files
Files are in Word format (DOCX)
Check the description to see the contents of each ZIP file
We do not share your information with any third party