ITERATIVE STRUCTURES Flashcards

1
Q

this allows you to efficiently use variables

A

repetition

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

general form of the while statement

A

while(expression)
statement

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

TRUE OR FALSE: while is not a reserved word

A

false

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

this acts as a decision maker and is usually a logical expression

A

expression

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

this is called the body of the loop

A

statement

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

continues to execute endlessly

A

infinite loop

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

infinite loops are avoided by this way

A

including statements in loop body that assure exit condition is eventually false

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

if you know exactly how many pieces of data need to be read, the while loop becomes a ____________

A

counter-controlled loop

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

in sentinel-controlled while loops, ________ is tested in the condition, and the loop ends when _______ is encountered

A

the sentinel variable, sentinel

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

a flag-controlled while loop uses a _____ variable to control the loop

A

bool

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

general form of a for loop

A

for(initial statement; loop condition; update statement)
statement

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

these are called for loop control statements

A

initial statement, loop condition, update statement

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

this usually initializes a variable (called the for loop control, or for indexed, variable)

A

initial statement

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

TRUE OR FALSE: c++ does not allow you to use fractional values for loop control variables of the double type

A

false

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

general form of a do while loop

A

do
statement
while(expression);

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

in a do while loop, the _________ executes first, and then the _________ is evaluated

A

statement, expression

17
Q

in a do while loop, it always iterates _________

A

at least once

18
Q

if you know or can determine in advance the number of repetitions needed, this loop is the correct choice

19
Q

if you do not know and cannot determine in advance the number of repetitions needed, and it could be zero, use this loop

A

while loop

20
Q

if you do not know and cannot determine in advance the number of repetitions needed, and it is at least once, use this loop

A

do while loop

21
Q

these alter the flow of control in loops

A

break and continue

22
Q

this is used for 2 purposes:
- to exit early from a loop (can eliminate the use of certain (flag) variables)
- to skip the remainder of a switch structure

A

break statement

23
Q

after the break statement executes, the program …?

A

continues with the first statement after the structure

24
Q

this is used in while, for, and do while loops

25
Q

when executed in a loop, this skips remaining statements and proceeds with the next iteration of the loop

26
Q

this is a piece of code written on top of an existing piece of code; intended to fix a bug in the original code

A

software patch

27
Q

TRUE OR FALSE: loops are harder to debug than sequence and selection structures

28
Q

set of statements that remains true each time the loop body is executed

A

use loop invariant

29
Q

this is the most common error associated with loops

A

off-by-one