Loops Flashcards

1
Q

In C, every loop has a _

A

controlling expression

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

If the expression is true

A

the loop continues to execute

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

Three iteration statements

A

while, do-while, for

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

repeatedly executes a target statement as long as a given condition is true

A

While loop

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

while loop syntax

A

Good!

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

These three things must be coordinated in order for the loop to work properly

A

initialized, tested, and updated

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

This is used in three ways

A

Loop Control Variable

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

In a while loop, if the condition is false, then

A

the loop will not execute

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

It is the post-test loop

A

do-while loop

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

This checks its condition at the bottom of the loop

A

do-while loop

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

This is guaranteed to execute at least one time

A

do-while loop

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

Do-while syntax

A

Wow!

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

While vs Do-While

A

while (first) - may execute 0 times
do-while (last) - must execute at least one time

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

similarities of while and do-while

A

one statement executed
initialization before loop
update during loop

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

A loop statements that is best for when you can determine in
advance how many times you need to execute the loop (counting loop).

A

For loop

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

The for statement includes the three parts needed for loops

A

initialize, test, and update

17
Q

All three loop statements are

A

functionally equivalent

18
Q

It is usually the best choice for loops that “count up”
(increment a variable) or “count down” (decrement a variable)

A

For statement