chapter 5 Flashcards

1
Q

When you use a loop, you can write one set of instructions that operates on multiple, separate sets of data.

A

true

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

A major advantage of having a computer perform complicated tasks is the ability to repeat them.

A

true

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

A loop is a structure that branches in two logical paths before continuing.

A

false

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

To make a while loop execute correctly, a loop control variable must be set to 0 before entering the loop.

A

false

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

To make a while loop execute correctly, a loop control variable should be tested before entering the loop body.

A

true

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

To make a while loop execute correctly, the body of the loop must take some action that alters the value of the loop control variable.

A

true

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

When one loop is nested inside another, the loop that contains the other loop is called the outer loop.

A

true

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

You need to create nested loops when the values of two or more variables repeat to produce every combination of values.

A

true

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

The number of times a loop executes always depends on a constant.

A

false

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

In a loop, neglecting to initialize the loop control variable is a mistake.

A

true

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

In a loop, neglecting to alter the loop control variable is a mistake.

A

true

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

In a loop, comparing the loop control variable using >= or <= is a mistake.

A

false

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

The for statement provides you with three actions in one compact statement: initializing, testing, and altering a loop control variable.

A

true

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

A for statement body always executes at least one time.

A

false

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

In most programming languages, you can provide a for loop with any step value.

A

true

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

In a while loop, the loop body might not execute.

17
Q

In a do-while loop, the loop body might not execute.

18
Q

The logic expressed by a do-while loop can always be expressed using a sequence and a while loop.

19
Q

In a structured loop, the loop-controlling evaluation must provide either the entry to or exit from the repeating structure.

20
Q

In a structured loop, the loop-controlling evaluation provides the only entry to or exit from the structure.

21
Q

If you need to perform a task, evaluate a condition, and perform an additional task, you cannot use a structured loop.

22
Q

An accumulator is a variable that you use to gather or accumulate values.

23
Q

An accumulator typically is initialized to 0.

24
Q

An accumulator is typically reset to 0 after it is output.

25
Q

Selection and loop structures differ in that selection structures only take action when a test condition is true.

26
Q

Selection and loop structures are similar in that the tested condition that begins either structure always has two possible outcomes.

27
Q

One difference between selection and loop structures is that the structure-controlling evaluation is repeated in a loop structure.