CSCI 111 Ch. 5 Quiz Flashcards

1
Q

A while loop is ? controlled

A

event

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

In a while loop, when am I NOT done?

A
  1. sentinel (-1, 0)
  2. flag (Boolean)
  3. counter
  4. end of file
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

While loop flow of control

A
  1. evaluate if condition T or F
  2. if T > execute
  3. return to header
  4. repeat until F
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

While loop syntax

A
while(condition) {
//loop body
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

A for loop is ? controlled

A

count

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

for loop flow of control

A
  1. initialize variable
  2. compare variable to condition
  3. if true, execute
  4. return to header, update variable
  5. repeat
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

for loop syntax

A
for(initialize variable; condition; update) {
//loop body
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

what makes do-while loops different?

A
  • guaranteed at least one iteration
  • condition evaluated after loop body
  • has ;
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

do while loop syntax

A
do {
//loop body
} while(condition);
How well did you know this?
1
Not at all
2
3
4
5
Perfectly