Deck 4: Looping
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/50
Play
Full screen (f)
Deck 4: Looping
1
When you do not know when you write the program whether the loop will be executed two times,200 times,or not at all you should use a definite loop.
False
2
Commonly,you control a loop's repetitions by using either a counter or a ____ value.
A) flag
B) keystone
C) control
D) sentinel
A) flag
B) keystone
C) control
D) sentinel
D
3
All programming languages assign 0 to a variable you fail to initialize explicitly.
False
4
The decision that controls every loop is always based on a ____ expression.
A) Boolean
B) numeric
C) conditional
D) contrived
A) Boolean
B) numeric
C) conditional
D) contrived
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
5
Just as with a selection,the Boolean comparison that controls a while loop must compare same-type values.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
6
If a data item is valid,you can assume that it is also correct.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
7
When a loop control variable is numeric,its value is often altered by ____ it,or adding to it.
A) decrementing
B) indicating
C) incrementing
D) increasing
A) decrementing
B) indicating
C) incrementing
D) increasing
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
8
The number of times a loop executes should always depend on a constant.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
9
It is always a mistake to fail to initialize a loop's control variable.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
10
A ____ is the structure that repeats actions while some condition continues.
A) decision
B) loop
C) branch
D) block
A) decision
B) loop
C) branch
D) block
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
11
You can use any of the ____ comparison operators to control a loop.
A) three
B) four
C) five
D) six
A) three
B) four
C) five
D) six
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
12
Most languages provide a built-in way to check whether a value that is entered is numeric or not.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
13
An accumulator is the same thing as a counter that you use to count loop iterations.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
14
While making decisions is what makes computers seem intelligent,it's looping that makes computer programming both efficient and worthwhile.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
15
A loop for which the number of iterations is predetermined is called a(n)____ loop,or counted loop.
A) infinite
B) definite
C) optimal
D) defined
A) infinite
B) definite
C) optimal
D) defined
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
16
Once your logic enters the body of a structured loop,you can exit the loop body early if you program it correctly.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
17
When you write a loop,you must control the number of repetitions it performs; if you do not,you run the risk of creating a(n)____ loop.
A) final
B) infinite
C) unbreakable
D) permanent
A) final
B) infinite
C) unbreakable
D) permanent
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
18
As long as a Boolean expression remains true,a ____ loop's body executes.
A) do
B) go
C) while
D) begin
A) do
B) go
C) while
D) begin
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
19
Some loops are controlled by reducing,or ____.
A) decrementing
B) incrementing
C) indicating
D) compensating
A) decrementing
B) incrementing
C) indicating
D) compensating
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
20
When you use a ____ within a computer program,you can write one set of instructions that operates on multiple,separate sets of data.
A) counter
B) variable
C) loop
D) sentinel
A) counter
B) variable
C) loop
D) sentinel
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
21
Many programs are not run at the command prompt in a text environment,but are run using a ____,which allows users to interact with a program in a graphical environment.
A) UML
B) GOOY
C) GUM
D) GUI
A) UML
B) GOOY
C) GUM
D) GUI
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
22
Program logic gets more complicated when you must use loops within loops,creating ____ loops.
A) interwoven
B) stacked
C) nested
D) connected
A) interwoven
B) stacked
C) nested
D) connected
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
23
When one loop is nested within another,the loop that is contained is the ____ loop.
A) outer
B) inner
C) controlling
D) bounding
A) outer
B) inner
C) controlling
D) bounding
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
24
Loops are frequently used to ____ data; that is,to make sure values fall within an acceptable or reasonable range.
A) validate
B) enter
C) add
D) manipulate
A) validate
B) enter
C) add
D) manipulate
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
25
When one loop is nested within another,the containing loop is the ____ loop.
A) inner
B) controlling
C) bounding
D) outer
A) inner
B) controlling
C) bounding
D) outer
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
26
The ____ statement uses a loop control variable and provides you with three actions automatically in one compact statement: initialization,evaluation and incrementation.
A) do
B) while
C) for
D) count
A) do
B) while
C) for
D) count
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
27
A(n)____ value is a number you use to increase a loop control variable on each pass through a loop.
A) jump
B) bump
C) increment
D) step
A) jump
B) bump
C) increment
D) step
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
28
Programmers use the term "____" to describe programs that are well designed and easy to understand and maintain.
A) simple
B) complex
C) elegant
D) classic
A) simple
B) complex
C) elegant
D) classic
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
29
Many programmers prefer starting their counted loops with a variable containing a(n)____ value.
A) 0
B) 1
C) arbitrary
D) constant
A) 0
B) 1
C) arbitrary
D) constant
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
30
A value such as "Y" or "N" that a user must supply to stop a loop is called a(n)____ value.
A) flag
B) sentinel
C) indicator
D) overlook
A) flag
B) sentinel
C) indicator
D) overlook
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
31
To indicate end-of-file,use the ____ indicator.
A) endfile
B) End-of-File
C) Control-z
D) eof
A) endfile
B) End-of-File
C) Control-z
D) eof
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
32
Often,the value of a loop control variable is not altered by arithmetic,but instead is altered by ____.
A) infinite loops
B) machine input
C) user input
D) the loop
A) infinite loops
B) machine input
C) user input
D) the loop
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
33
Business reports that list no individual detail records,just totals,are called ____ reports.
A) overall
B) summary
C) executive
D) roll-up
A) overall
B) summary
C) executive
D) roll-up
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
34
A(n)____ is any numeric variable you use to count the number of times an event has occurred.
A) accumulator
B) holder
C) scratchpad
D) counter
A) accumulator
B) holder
C) scratchpad
D) counter
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
35
A(n)____ is a variable that you use to gather or accumulate values.
A) indicator
B) holder
C) accumulator
D) aggregator
A) indicator
B) holder
C) accumulator
D) aggregator
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
36
The ____ is the location on your computer screen at which you type entries to communicate with the computer's operating system using text.
A) command prompt
B) command shell
C) input prompt
D) run prompt
A) command prompt
B) command shell
C) input prompt
D) run prompt
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
37
Which of the following is NOT a mistake that programmers commonly make with loops?
A) Neglecting to initialize the loop control variable
B) Using the wrong comparison with the loop control variable
C) Neglecting to alter the loop control variable
D) Including statements outside the loop that belong inside the loop
A) Neglecting to initialize the loop control variable
B) Using the wrong comparison with the loop control variable
C) Neglecting to alter the loop control variable
D) Including statements outside the loop that belong inside the loop
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
38
With a ____ loop,the loop body executes once before the loop-controlling condition is tested.
A) do-while
B) while
C) do
D) for
A) do-while
B) while
C) do
D) for
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
39
Reports that include some output for every input record are ____ reports.
A) summary
B) detail
C) executive
D) running total
A) summary
B) detail
C) executive
D) running total
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
40
Every high-level computer programming language contains a ____ statement that you can use to code any loop,including both indefinite and definite loops.
A) do
B) while
C) for
D) count
A) do
B) while
C) for
D) count
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
41
The following pseudocode is not working properly.The message should display five times.This is not working because the programmer made which common loop mistake? Declarations
Num count
String message = "OK"
While count < 5
Output message
Count = count + 1
Endwhile
A) Neglecting to initialize the loop control variable
B) Neglecting to alter the loop control variable
C) Using the wrong comparison with the loop control variable
D) Including statements inside the loop that belong outside the loop
Num count
String message = "OK"
While count < 5
Output message
Count = count + 1
Endwhile
A) Neglecting to initialize the loop control variable
B) Neglecting to alter the loop control variable
C) Using the wrong comparison with the loop control variable
D) Including statements inside the loop that belong outside the loop
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
42
Using a while loop,write the pseudocode to display "I love programming!" five times.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
43
The following pseudocode is not working properly.The message should display five times.What needs to be changed? Declarations
String message = "OK"
While count < 5
Output message
Count = count + 1
Endwhile
A) while count < 5 should be changed to while count = 5
B) num count = 1 should be added to the Declarations
C) num count should be added to the Declarations
D) num count = 0 should be added to the Declarations
String message = "OK"
While count < 5
Output message
Count = count + 1
Endwhile
A) while count < 5 should be changed to while count = 5
B) num count = 1 should be added to the Declarations
C) num count should be added to the Declarations
D) num count = 0 should be added to the Declarations
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
44
In the following pseudocode,what will be the value of sum after the code is run? Declarations
Num count = 0
Num sum = 0
While count < 3
For X = 1 to 2 step 1
Sum = sum + X
Endfor
Count = count + 1
Endwhile
A) 3
B) 6
C) 9
D) 12
Num count = 0
Num sum = 0
While count < 3
For X = 1 to 2 step 1
Sum = sum + X
Endfor
Count = count + 1
Endwhile
A) 3
B) 6
C) 9
D) 12
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
45
The following pseudocode is not working properly.The message should display 10 times.What needs to be changed? for count = 0 to 10
Output "I love programming!"
Endfor
A) The for statement should be:
For count = 0 to 9
B) The for statement should be:
For count = 0 to 9 step 1
C) The for statement should be:
For count = 0 to 10 step 1
D) The for statement should be:
For count = 0 to 8 step 1
Output "I love programming!"
Endfor
A) The for statement should be:
For count = 0 to 9
B) The for statement should be:
For count = 0 to 9 step 1
C) The for statement should be:
For count = 0 to 10 step 1
D) The for statement should be:
For count = 0 to 8 step 1
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
46
Name the three crucial steps that must occur in every loop.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
47
The following pseudocode is not working properly.The message should display 10 times.This is not working because the programmer made which common loop mistake? for count = 1 to 10
Output "Hello"
Endfor
A) Neglecting to initialize the loop control variable
B) Neglecting to alter the loop control variable
C) Using the wrong comparison with the loop control variable
D) Including statements inside the loop that belong outside the loop
Output "Hello"
Endfor
A) Neglecting to initialize the loop control variable
B) Neglecting to alter the loop control variable
C) Using the wrong comparison with the loop control variable
D) Including statements inside the loop that belong outside the loop
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
48
Using a for loop,write the pseudocode to display "I love programming!" five times.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
49
Write the logic for a program that outputs every even number from 2 through 16.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
50
Name three common mistakes that programmers make when programming with loops.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck