Deck 5: Repetition

Full screen (f)
exit full mode
Question
A loop iteration is also called a pass through the loop.
Use Space or
up arrow
down arrow
to flip the card.
Question
Not all loops require a condition that must be evaluated.
Question
Valid loop conditions are identical to those used in selection statements.
Question
In every loop there must be a statement within the repeating section of code that alters the condition so that it eventually becomes false.
Question
A pretest loop is also called an exit-controlled loop.
Question
A posttest loop is also called an entranced-controlled loop.
Question
The switch statement is a general repetition statement that can be used in a variety of programming situations.
Question
The general form of the while statement is:
statement;
while (expression);
Question
The transfer of control back to the start of a while statement to reevaluate the expression is known as a program loop.
Question
Symbolic constants can be extremely useful in constructing loops because they indicate what the number in the tested condition represents.
Question
Loops are rarely used for the computation of sums and averages of lists of numeric data.
Question
An average is computed by dividing the final total or accumulated value by the number of items that were added.
Question
Care must be taken when choosing sentinel values.
Question
If we were constructing a program that accepts student grades, a good sentinel value would be 0.
Question
In C, EOF stands for End Of Format.
Question
The actual value of EOF is compiler-dependent, but it is always assigned a code that is not used by any other character.
Question
The stdio.h file contains the definition of EOF.
Question
A break statement forces an immediate break, or exit, from switch and while statements only.
Question
The break statement violates pure structured programming principles because it provides a second, nonstandard exit from a loop.
Question
When a continue statement is encountered in a loop, the next iteration of the loop begins immediately.
Question
In many situations, especially those that use a counter-controlled loop, the for statement format is easier to use than its while equivalent.
Question
The construction for ( ; count <= 20;) is not valid.
Question
In C, lists where commas are required to separate individual expressions in the list, are referred to as comma-separated lists.
Question
Nested loops have a loop contained within another loop.
Question
The first loop of a nested loop is called the inner loop.
Question
The input data validation application is ideally suited for a pretest loop.
Question
A section of code that is repeated is referred to as a ____.

A)condition
B)selection
C)repetition
D)loop
Question
Once a repetition statement is chosen, the other ____ elements of a loop are generally controlled by a single loop-control variable.

A)two
B)three
C)four
D)five
Question
In a(n) ____ loop the condition is tested at the end of the repeating section of code.

A)pretest
B)posttest
C)fixed-count
D)condition-controlled
Question
In a(n) ____ loop the condition the tested condition does not depend on a count being achieved, but rather on a specific value being encountered.

A)pretest
B)posttest
C)fixed-count
D)condition-controlled
Question
A(n) ____ is a condition-controlled loop where one specific value is required to terminate the loop.

A)input-validation
B)sentinel-controlled
C)condition-controlled
D)counter-controlled
Question
A(n) ____ loop is a condition-controlled loop that terminates when a value within a valid range is entered.

A)input-validation
B)sentinel-controlled
C)condition-controlled
D)counter-controlled
Question
The ____ statement literally loops back on itself to recheck the expression until it evaluates to 0 (becomes false).

A)for
B)switch
C)do-while
D)while
Question
In the following statements, the printf statement will be executed ____ times.
Count = 10;
While (count <= 10)
Printf("%d ",count);

A)0
B)1
C)10
D)an infinite number of
Question
The output of the following code is ____.
Count = 1; /* initialize count */
While (count <= 10)
{
Printf("%d ",count);
Count++; /* increment count */
}

A)1 1 1 1 1 1 1 1 ...
B)1 2 3 4 5 6 7 8 9
C)1 2 3 4 5 6 7 8 9 10
D)1 2 3 4 5 6 7 8 9 10 11
Question
total = total + num; is equivalent to ____.

A)total += num;
B)total =+ num;
C)total ++ num;
D)total +=+ num;
Question
____ is an accumulating statement.

A)total += num;
B)total++;
C)++total;
D)total* = num;
Question
Before accumulating values, the accumulator variable should be initialized to ____.

A)-1
B)0
C)1
D)NULL
Question
In Unix operating systems, the EOF mark is generated whenever the ____ keys are pressed simultaneously.

A)Ctrl and D
B)Ctrl and E
C)Ctrl and F
D)Ctrl and Z
Question
In IBM-compatible computers, the EOF mark is generated whenever the ____ keys are pressed simultaneously.

A)Ctrl and D
B)Ctrl and E
C)Ctrl and F
D)Ctrl and Z
Question
The ____ statement is similar to the break statement but applies only to loops created with while, do-while, and for statements.

A)stop
B)loop
C)exit
D)continue
Question
The statement ____ is a null statement.

A)NULL
B)NULL;
C)break;
D);
Question
The need to initialize variables or make some other evaluations prior to entering a repetition loop is so common that the ____ statement allows all the initializing statements to be grouped together as the first set of items within the statement's parentheses.

A)for
B)while
C)do-while
D)switch
Question
The ____ semicolons must always be present within the for statement's parentheses.

A)two
B)three
C)four
D)five
Question
Omitting the ____ expression in a for statement results in an infinite loop.

A)initializing
B)altering
C)tested
D)break
Question
The second loop of a nested loop is called the ____ loop.

A) inner
B) outer
C) slave
D) conditioned
Question
The ____ statement always creates a posttest loop.

A) while
B) do-while
C) for
D) repeat-until
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/47
auto play flashcards
Play
simple tutorial
Full screen (f)
exit full mode
Deck 5: Repetition
1
A loop iteration is also called a pass through the loop.
True
2
Not all loops require a condition that must be evaluated.
False
3
Valid loop conditions are identical to those used in selection statements.
True
4
In every loop there must be a statement within the repeating section of code that alters the condition so that it eventually becomes false.
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
5
A pretest loop is also called an exit-controlled loop.
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
6
A posttest loop is also called an entranced-controlled loop.
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
7
The switch statement is a general repetition statement that can be used in a variety of programming situations.
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
8
The general form of the while statement is:
statement;
while (expression);
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
9
The transfer of control back to the start of a while statement to reevaluate the expression is known as a program loop.
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
10
Symbolic constants can be extremely useful in constructing loops because they indicate what the number in the tested condition represents.
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
11
Loops are rarely used for the computation of sums and averages of lists of numeric data.
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
12
An average is computed by dividing the final total or accumulated value by the number of items that were added.
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
13
Care must be taken when choosing sentinel values.
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
14
If we were constructing a program that accepts student grades, a good sentinel value would be 0.
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
15
In C, EOF stands for End Of Format.
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
16
The actual value of EOF is compiler-dependent, but it is always assigned a code that is not used by any other character.
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
17
The stdio.h file contains the definition of EOF.
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
18
A break statement forces an immediate break, or exit, from switch and while statements only.
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
19
The break statement violates pure structured programming principles because it provides a second, nonstandard exit from a loop.
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
20
When a continue statement is encountered in a loop, the next iteration of the loop begins immediately.
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
21
In many situations, especially those that use a counter-controlled loop, the for statement format is easier to use than its while equivalent.
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
22
The construction for ( ; count <= 20;) is not valid.
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
23
In C, lists where commas are required to separate individual expressions in the list, are referred to as comma-separated lists.
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
24
Nested loops have a loop contained within another loop.
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
25
The first loop of a nested loop is called the inner loop.
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
26
The input data validation application is ideally suited for a pretest loop.
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
27
A section of code that is repeated is referred to as a ____.

A)condition
B)selection
C)repetition
D)loop
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
28
Once a repetition statement is chosen, the other ____ elements of a loop are generally controlled by a single loop-control variable.

A)two
B)three
C)four
D)five
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
29
In a(n) ____ loop the condition is tested at the end of the repeating section of code.

A)pretest
B)posttest
C)fixed-count
D)condition-controlled
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
30
In a(n) ____ loop the condition the tested condition does not depend on a count being achieved, but rather on a specific value being encountered.

A)pretest
B)posttest
C)fixed-count
D)condition-controlled
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
31
A(n) ____ is a condition-controlled loop where one specific value is required to terminate the loop.

A)input-validation
B)sentinel-controlled
C)condition-controlled
D)counter-controlled
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
32
A(n) ____ loop is a condition-controlled loop that terminates when a value within a valid range is entered.

A)input-validation
B)sentinel-controlled
C)condition-controlled
D)counter-controlled
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
33
The ____ statement literally loops back on itself to recheck the expression until it evaluates to 0 (becomes false).

A)for
B)switch
C)do-while
D)while
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
34
In the following statements, the printf statement will be executed ____ times.
Count = 10;
While (count <= 10)
Printf("%d ",count);

A)0
B)1
C)10
D)an infinite number of
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
35
The output of the following code is ____.
Count = 1; /* initialize count */
While (count <= 10)
{
Printf("%d ",count);
Count++; /* increment count */
}

A)1 1 1 1 1 1 1 1 ...
B)1 2 3 4 5 6 7 8 9
C)1 2 3 4 5 6 7 8 9 10
D)1 2 3 4 5 6 7 8 9 10 11
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
36
total = total + num; is equivalent to ____.

A)total += num;
B)total =+ num;
C)total ++ num;
D)total +=+ num;
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
37
____ is an accumulating statement.

A)total += num;
B)total++;
C)++total;
D)total* = num;
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
38
Before accumulating values, the accumulator variable should be initialized to ____.

A)-1
B)0
C)1
D)NULL
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
39
In Unix operating systems, the EOF mark is generated whenever the ____ keys are pressed simultaneously.

A)Ctrl and D
B)Ctrl and E
C)Ctrl and F
D)Ctrl and Z
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
40
In IBM-compatible computers, the EOF mark is generated whenever the ____ keys are pressed simultaneously.

A)Ctrl and D
B)Ctrl and E
C)Ctrl and F
D)Ctrl and Z
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
41
The ____ statement is similar to the break statement but applies only to loops created with while, do-while, and for statements.

A)stop
B)loop
C)exit
D)continue
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
42
The statement ____ is a null statement.

A)NULL
B)NULL;
C)break;
D);
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
43
The need to initialize variables or make some other evaluations prior to entering a repetition loop is so common that the ____ statement allows all the initializing statements to be grouped together as the first set of items within the statement's parentheses.

A)for
B)while
C)do-while
D)switch
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
44
The ____ semicolons must always be present within the for statement's parentheses.

A)two
B)three
C)four
D)five
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
45
Omitting the ____ expression in a for statement results in an infinite loop.

A)initializing
B)altering
C)tested
D)break
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
46
The second loop of a nested loop is called the ____ loop.

A) inner
B) outer
C) slave
D) conditioned
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
47
The ____ statement always creates a posttest loop.

A) while
B) do-while
C) for
D) repeat-until
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
locked card icon
Unlock Deck
Unlock for access to all 47 flashcards in this deck.