Ch.6 More about Loops and Decisions Test Questions & Answers - Practice Test Bank | Prelude Programming 6e Venit by Stewart Venit. DOCX document preview.

Ch.6 More about Loops and Decisions Test Questions & Answers

Test Bank for Prelude to Programming Chapter 6

MULTIPLE CHOICE

1. If Number = 4, what possible numbers can result from:

Floor(Random()() * 10) + Number

a.

1, 2, 3, 4

b.

0, 1, 2, 3, 4

c.

0, 1, 2, 3

d.

4, 5, 6, 7, 8, 9, 10, 11, 12, 13

2. If Number = 4, what possible numbers can result from

Floor(Random() * Number)

a.

1, 2, 3, 4

b.

0, 1, 2, 3, 4

c.

0, 1, 2, 3

d.

4, 5, 6, 7, 8, 9, 10, 11, 12, 13

3. What is the output of the code corresponding to the following pseudocode?

Declare X As Integer

Declare Y As Integer

For (X = 1; X <=2; X++)

For (Y = 3; Y <= 4; Y++)

Write X * Y

End For(Y)

End For(X)

a.

3

4

6

8

b.

4

5

5

6

c.

1

3

2

4

d.

3 4

6 8

4. What is the output of the code corresponding to the following pseudocode?

Declare Y As Integer

Declare X As Integer

For (Y = 1; Y <=2; Y++)

For (X = 3; X <= 4; X++)

Write Y * X

End For(X)

End For(Y)

a.

3

4

6

8

b.

4

5

5

6

c.

1

3

2

4

d.

3 4

6 8

5. What is the output of code corresponding to the following pseudocode?

Declare A As Integer

Declare B As Float

Set A = 2

While <= 3

Set B = 2.5 * A

Write B

Set B = Int(B)

Write B

Set A = A + 1

End While

a.

5

7

b.

5

5

7.5

7

c.

5

5

7

7

d.

2

5

3

7

6. Which of the following loops cannot be nested in a For loop?

a.

While

b.

For

c.

Repeat ... Until

d.

Do ... While

e.

all of the above can be nested in a For loop

7. What is the output of the code corresponding to the pseudocode shown?

Declare G As Integer

Declare H As Integer

Set G = 7

While G <= 8

Set H = 6

While H <= 7

Write G + H

Set H = H + 1

End While(H)

Set G = G + 1

End While(G)

a.

13

14

15

b.

7

6

7

8

c.

7 6

7 7

8 6

8 7

d.

13

14

14

15

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

Declare A As Integer

Declare B As Integer

Declare C As Integer

Set A = 3

While A <= 6

Set B = (2 * A) – 1

Write B

Set C = A

While C <= (A+1)

Write C

Set C = C + 1

End While(C)

Set A = A + 2

End While(A)

a.

5

3

9

5

b.

3

5

4

5

9

5

c.

5

3

4

9

5

6

d.

5

3

3

9

5

5

9. Which of the following statements should be used to validate that a number input by the user into a variable named Widgets is an integer value?

a.

While Widgets != Widgets

Write “Please enter an integer value:”

Input Widgets

End While

b.

While Int(Widgets) != Widgets

Write “Please enter an integer value:”

Input Widgets

End While

c.

Repeat

Write “Please enter an integer value:”

Input Widgets

End Repeat

d.

While Widgets > 0

Write “Please enter an integer value:”

Input Widgets

End While

10. What does the following program segment do?

Declare Count As Integer

Declare Sum As Integer

Set Sum = 0

For (Count = 1; Count < 50; Count++)

Set Sum = Sum + Count

End For

a.

It sums all the integers from 0 through 50

b.

It sums all the integers from 1 through 50

c.

It sums all the integers from 1 through 49

d.

It does nothing since there is no Write statement

11. What is wrong with the following pseudocode?

Declare Count As Integer

Declare TheNumber As Integer

Set TheNumber = 12

For (Count = 10; Count>TheNumber; Count--)

Write TheNumber + Count

End For

a.

A counter must start at 0 or 1

b.

The limit condition in a For loop cannot be a variable

c.

The loop will never be entered since the initial value of Count is less than the test condition

d.

The loop will never end since the test condition will never be met

12. If MyNumber = 7.82, what is the value of Int(MyNumber/2)+ 0.5?

a.

4.41

b.

3.5

c.

3.91

d.

4.5

13. What is the output of the code corresponding to the following pseudocode?

Declare M As Integer

Declare P As Integer

Repeat

Set P = 1

While P < 4

Write M + “ and “ + P

Set P = P + 1

End While(P)

Set M = M + 1

Until M = 3

a.

2 and 1

3 and 1

b.

2 and 1

2 and 2

2 and 3

3 and 1

3 and 2

3 and 3

c.

1 and 1

2 and 2

3 and 3

d.

M and P

M and P

M and P

14. Which statement would produce an output of one of the following numbers:

5, 6, 7, 8, 9, 10

a.

Floor(Random() * 5) + 5

b.

Floor(Random() * 6) + 5

c.

Floor(Random()) + 5

d.

Floor(Random() * 9) - 5

15. What is displayed when the following pseudocode is coded and run, given that the input is “Harold”?

Declare Star As Character

Declare A As Integer

Declare Count As Integer

Declare Name As String

Set Star = “*”

Write “Enter your first name: “

Input Name

Set A = Length_Of(Name)

Set Count = 1

Print Name

Print <NL>

While Count <= A

Print Star

Set Count = Count + 1

End While

a.

Harold

*

b.

Harold

*****

c.

******

d.

Harold

******

TRUE/FALSE

1. True/False: It is possible to have both a Select Case statement and an If-Then

structure within a single loop.

  1. True/False: If Number = 4, is the following statement true or false:

Int(Number * Number) == Number * Number

  1. True/False: If Number = 2.7, is the following statement true or false:

Int(Number * Number) == Number * Number

4. True/False: If one For loop is nested within another, then the limit value for the two loops must be different.

5. True/False: Two non-overlapping loops can be nested within a third loop.

6. True/False: If Number = 3, indicate whether the following statement is true

or false:

Floor(Random() * Number) may be 0, 1, 2, or 3

7. True/False: A For loop may not be nested within a While loop.

  1. True/False: Given that Number = 3:

Floor(Random() * Number) + 4 may be 7, 8, 9, 10, 11, 12, or 13

  1. True/False: Given that Number = 3:

Floor(Random() * 4) + Number may be 3, 4, 5, or 6

10. True/False: It is not possible to put a loop inside an If-Then statement.

11. True/False: If Number = 2.3, is the following statement true or false:

Number == Int(Number)

12. True/False: A counter in a loop can count up by fives.

13. True/False: Is the following statement true or false?

Ceiling(6.89) = 6

14. True/False: In a program with nested loops, the inner loop is completed before the outer loop.

15. True/False: Is the following statement true or false?

Ceiling(4.22) = 5

SHORT ANSWER

1. Numbers that form an unpredictable sequence in which each number is equally likely to occur are called __________ __________.

2. ____________ __________ are numbers that belong to a sequence, generated by a

mathematical algorithm, in which each number is equally likely to occur.

3. The starting value of an algorithm used to generate a range of numbers is called the _________.

4. The expression Floor(Random()*6) produces the numbers _____ through _____

5. When one loop is contained within another loop, we say these are __________ loops.

6. The statement

If Int(Number) != Number Then...

checks to see if the value of Number is a(n) _________.

7. In a program with nested loops, the outer loop is completed __________ (before/after) the inner loop.

8. If a counter named MyCount in a For loop has the value of 5 on the first pass, 10 on the second pass, 15 on the third pass, and so on, the increment would be written as __________.

9. If a counter named MyCount in a For loop has the initial value of 5 on the first pass and we want it to go through 4 iterations, increasing its value by 5 on each pass, the test condition would be written as __________.

10. The function that returns the number of characters in a string is the __________ function.

Document Information

Document Type:
DOCX
Chapter Number:
6
Created Date:
Aug 21, 2025
Chapter Name:
Chapter 6 More about Loops and Decisions
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