CSCI 111 Ch. 5 Quiz Flashcards
1
Q
A while loop is ? controlled
A
event
2
Q
In a while loop, when am I NOT done?
A
- sentinel (-1, 0)
- flag (Boolean)
- counter
- end of file
3
Q
While loop flow of control
A
- evaluate if condition T or F
- if T > execute
- return to header
- repeat until F
4
Q
While loop syntax
A
while(condition) { //loop body }
5
Q
A for loop is ? controlled
A
count
6
Q
for loop flow of control
A
- initialize variable
- compare variable to condition
- if true, execute
- return to header, update variable
- repeat
7
Q
for loop syntax
A
for(initialize variable; condition; update) { //loop body }
8
Q
what makes do-while loops different?
A
- guaranteed at least one iteration
- condition evaluated after loop body
- has ;
9
Q
do while loop syntax
A
do { //loop body } while(condition);