Chapter 5 Flashcards

1
Q

Inside the brackets of the loop is a _____ expression. This means the loop continues until the Boolean expression is ______

A

Boolean

False

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

What is the syntax for a while loop

A

While (loop-continuation-condition)
{
Statement(s)
}

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

Can you use floating point values for equality checking in a loop expression?

A

No because floating point numbers are an approximation

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

What is the function of eof()?

A

When reading text from a file it will terminate a loop when the end of the file is reached?

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

Eof returns _____ when the end of the file is reached. Because of this it is to have the syntax written like….

A

True

While (!input.eof())

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

A do while loop is the same as a while loop except that…..

A

It executes the loop first and then checks the loop condition

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

What is the syntax of a do while loop?

A

do
{
Statement(s)
} while (loop-continuation-condition)

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

what is the syntax of a for loop

A

for (intial-action; loop-continuation-condition; action-after-each-iteration)
{
statement(s)
}

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

a for loop generally uses a variable to control how many times the loop body is executed and when the loop terminates, this is called a _____ _____

A

control variable

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

the initial-action in a for loop often _____ the control variable.

A

intializes

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

the action-after-each-iteration in a for loop usually ____ or ____ the control variable

A

increments

decrements

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

the loop-continuation-condition in a for loop tests wether the control varibale has….

A

reached termination variable

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

for loops and while loops are called ____ loops

A

pretest

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

do-while are called ____ loops

A

postest

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

in general, a ____ loop is if the number of repetitions is known in advance

A

for

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

in general, a _____ loops is used when the number of repetitions is not fixed

A

while

17
Q

a ____ loop is used when you want to execute the statements before the continuation condition is tested

A

before

18
Q

a semi colon is needed to end a lop for ____ loops

A

do-while

19
Q

____ breaks out of an iteration while ___ breaks out of the loop

A

continue

break

20
Q

a while loop executes statements repeatedly while the conditon is _____

A

true

21
Q

in the while and do-while loops, the loop-continuation-condition is evaluated immediately ____ the continue statement

A

after

22
Q

in the for loop, the ____-_____-____-_____ is preformed, THEN the loop-continuation-condition is evaluated, immediately after the continue statement

A

action after each iteration