Professional Documents
Culture Documents
STRUCTURE
Instructions need to be repeated more than one
time to process lots of data
Could do it by just literally repeating the code,
by copy and paste
But that isn't flexible, nor is it easy to keep
consistent
Need a "loop"
TWO PARTS TO REPETITION
A Body
what needs to be repeated
must be marked off in some fashion like {}
A Control expression
some way to make the repetition stop when
desired
{
statement;
statement;
statement;
}
Indentation useful for humans, not compiler
THE SEMANTICS OF A WHILE
The condition at the top of the loop is evaluated
to see if it is true or false
it MUST be - will be forced to bool !