Simple Looping
Most interesting programs need to do more than just execute from beginning to end.
Think of processes that repeat (or have parts that repeat)
Grading papers
Baking cookies
Playing football
Shampooing your hair :-)
A pacemaker
Video games (play again?)
Anti-lock breaks
To repeat a statement or group of statements in a C++ program we use the "while" statement.
Syntax: while (boolean-expression) statement;
Example: The code below write "tick" to the screen 3 times.
counter = 3;
while (counter > 0) {
cout << "tick ";
counter = counter - 1; // could write counter--;
}