Ch. 5.2: Introduction to Loops: The while Loop Flashcards
What is a loop?
A loop is a control structure that causes a statement or group of statements to repeat.
What is a loop header?
It consists of the key word while followed by an expression enclosed in parentheses.
What is the body of the loop?
Is the conditionally executed statement, because it is executed only under the condition that the expression is true.
What is a while loop?
The while loop works like an if statement that executes over and over. As long as the expression inside the parenthesis is true, the conditionally executed statement or block will repeat.
What is an iteration?
Each repetition of a loop.
What is the loop control variable?
The variable that controls the number of times the loop iterates.
What is a pretest loop?
This means it tests its expression before each iteration.
What is an infinite loop?
An infinite loop continues to repeat until the program is interrupted.