// Mr. Minich
// CMPSC 201
// Ch. 5 Demo Program #2
// January 30, 2000 // Purpose - to illustrate the use of the while and do while loops
#include <iostream> using namespace std; int main() { int loopVariable = 0; // loop variable while (loopVariable < 10) { cout << loopVariable << endl; loopVariable += 1; }
// The values of 0 through and including 9 are displayed. // What is the final value of loopVariable?
loopVariable = 100; do { loopVariable--;
cout << loopVariable << endl; } while (loopVariable >= 0); // Predict what values will be displayed. // Notice the use of the decrementing operator. // Also notice the necessary semicolon after the // the control expression.

return 0; }// end of main