Chapter 5 - Repetition Structures: Looping
Both (1)____________ . . . Until and (2)___________ . . .While loops are post-test loops.
1) Repeat 2) Do
If Number1 = 19.86 and Number2 = 2.94, what value results from the following statement? Int(Number1) + Int(Number2)
21
Which of the following conditional statements will evaluate as True? A) (15 * 2 > 30) AND (15 - 2 < 30) B) (15 * 2 <= 30) OR (15 - 2 > 30) C) (15 * 2 <= 30) AND (15 - 2 > 30) D) (15 * 2 < 30) OR (15 - 2 > 30)
B) (15 * 2 <= 30) OR (15 - 2 > 30)
If MyNumber = 6.8, what is the value of Int(MyNumber * 4^2)? A) 108.8 B) 108 C) this is an illegal operation D) 109
B) 108
Given: Count = 23, what is the value of Count after the following statement is executed: Count = Count + 2 A) 23 B) 25 C) 24 D) 48
B) 25
If Apples = 6, what will be displayed after code corresponding to the following pseudocode is run? While Apples < 0 Write "You can't eat " + Apples + "at one time!" End While Write "Goodbye, apple lover." A) You can't eat 6 apples at one time! Goodbye, apple lover. B) Goodbye, apple lover. C) You can't eat apples at one time! D) Nothing will display
B) Goodbye, apple lover.
What statements are in the body of the following loop? Set Number = 12 For (I = 1; I <= 15; I++) Write "Enter a number: " Input Number Write "That's a good number." End For Write "Bye bye." A) Write "Enter a number: ", Write "That's a good number.", Write "Bye bye." B) Input Number C) Set Number = 12, Write "Bye bye." D) Set Number = 12, Write "Enter a number: ", Write "That's a good number."
B) Input Number
A counter must be: A) a variable named Count B) an integer C) a positive number D) a real number
B) an integer
If A = 5 and B = 3, what will be displayed when code corresponding to the following pseudocode is run? (In the answer options, new lines are separated by commas.) Do Write A^2 Set A = A - 1 While A >= B A) 25, 16, 9, 4 B) 25, 16 C) 25, 16, 9 D) 9, 9, 9
C) 25, 16, 9
What will be displayed after code corresponding to the following pseudocode is run? Write "Loops are fun!" For (Count = 8; Count > 4; Count-2) Write "Hooray!" End For A) Loops are fun! B) Loops are fun! Hooray! Hooray! Hooray! C) Loops are fun! Hooray! Hooray! D) nothing will display
C) Loops are fun! Hooray! Hooray!
What input can cause this loop to end? Declare Number, ComputerNumber As Integer Do Write "Please enter a number: " Input Number ComputerNumber = Number + 1 Write Number While Number <= ComputerNumber Write "The End" A) 0 B) 1 C) Nothing would cause this loop to end; it is an infinite loop. D) 12
C) Nothing would cause this loop to end; it is an infinite loop.
What is the value of Number, given the following: A = 4.2, B = 6, C = 1.5 Set Number = Ceiling(A + B * C) A) 15 B) 13.2 C) 13 D) 14
D) 14
If Number = 7, what will be displayed after code corresponding to the following pseudocode is run? (In the answer options, new lines are separated by semi-colons.) For (Count = 5; Count <= Number; Count++) Write Count + ", " + Count * 2 End For A) 5, 10; 6, 12 B) 5, 10; 7, 14 C) 5, 7; 10, 14 D) 5, 10; 6, 12; 7, 14
D) 5, 10; 6, 12; 7, 14
What will be displayed if code corresponding to the following pseudocode is executed? Set Number = 4 Repeat Write 2 * Number Set Number = Number + 2 Until Number >= 8 A) 4, 8, 12 B) 8, 12 C) 12, 16 D) 8, 12, 16
D) 8, 12, 16
Given that the variables MyName and YourName are defined as follows, which conditional statement will evaluate as True? Set MyName = "Elizabeth" Set YourName = "Mike" A) YourName <= MyName B) MyName > YourName C) MyName == YourName D) YourName >= MyName
D) YourName >= MyName
If the following statement is the first line of a For loop, ______ is the limit value. For (X = 1; X <= N; X+3)
N
What does the following comparison statement evaluate to? Int(6.89) == 6 ~It wants to know if this statement is true or false.
True
To __________ data means to ensure that the data are in the proper range.
validate
What would make this comparison statement False? Complete with the appropriate relational operator. "G" _____= "G"
!
If Number1 = 12.2 and Number2 = 13.3, what value results from the following expression? Floor(Number1) + Ceiling(Number2)
??? 26
If a For loop's increment is positive, then the body of the loop will not be executed if the initial value is __________ than the limiting value.
??? greater
What will be displayed after code corresponding to the following pseudocode is run? (In the answer options, new lines are separated by commas.) Set Count = 10 While Count > 0 Write Count Set Count = Count - 2 End While A) 10, 8, 6, 4, 2 B) 8, 6, 4, 2, 0 C) 10, 8, 6, 4, 2, 0 D) 8, 6, 4, 2
A) 10, 8, 6, 4, 2
If N = 5, what is displayed when the following pseudocode is coded and run? Set A = 2 For (B = 1; B <=N; B++) Set A = A + 2 * B End For Write A A) 32 B) 22 C) 18 D) 16 ~I don't know why the answer is what it is...
A) 32
What is the value of Number, given the following: A = 3.2, B = 6, C = 8 Set Number = Floor(A + C / B) A) 4 B) 4.87 C) 4.9 D) 1.125
A) 4
If Count = 1 and X = 3, what will be displayed when code corresponding to the following pseudocode is run? Do Set Y = Count + X Write Y Set Count = Count + 1 While Count <= X A) 4, 5, 6 B) 1, 3, 5 C) 4, 5, 6, 7 D) 3, 4, 5, 6
A) 4, 5, 6
What will be displayed after code corresponding to the following pseudocode is run? (In the answer options, new lines are separated by commas.) Set Count = 2 While Count < 10 Set Count = Count + 2 Write Count End While A) 4, 6, 8, 10 B) 2, 4, 6, 8 C) 4, 6, 8 D) 2, 4, 6, 8, 10
A) 4, 6, 8, 10
What is the value of Number, given the following: A = 2.3, B = 3.8 Set Number = Floor(Ceiling(A) + B) A) 6 B) 8 C) 8.74 D) 6.1
A) 6
A variable that holds the accumulated result of a sum is called a(n) __________.
accumulator
If Number1 = 19.86 and Number2 = 2.94, what value results from the following statement? Int(Number1 + Number2)
22
If Number1 = 12.2 and Number2 = 13.3, what value results from the following expression? Int(Ceiling(Number1) + Ceiling(Number2))
27
Which of the following is not a type of loop? A) For B) While C) Do... While D) Repeat... Until E) All of these are types of loops
E) All of these are types of loops
A loop that is executed a fixed number of times, where that number is known before entering the loop for the first time, is known as a(n) __________ controlled loop.
counter
A variable that keeps track of the number of passes through a loop is known as a(n) __________.
counter
For readability, most programs __________ the body of a loop.
indent
If a condition in a post-test loop can never be met, the loop is an _________ loop.
infinite
When a loop counter is set to its first value, it is said to be __________.
initialized
A single pass through a loop is known as a loop __________.
iteration
The number of passes through a loop is known as the number of loop __________.
iterations
If the increment of a For loop is negative, then the body of the loop will not be executed if the initial value is _______ than the limit value.
less
The body of a ______-test loop is always executed at least once.
post
One way to force a loop to end is to have the user enter a special item, called a(n) ___________ value which acts as a signal that input is complete.
sentinel