// // Filename: pgm2_4b.cpp // // Description: Demonstration of the pre and post increment operators // used within while loops. // // ENSC 104: Digital Computer Programming // // Instructor: Dr. Walsh // // Section: 2 // // Date Created: 02/14/98 // Last Modified: 02/14/98 // // Name: N/A // #define COUNT 5 #include main() { int counter = 1; // Pre Increment within body of loop cout << "Pre Increment within body of loop" << endl; while ( counter <= COUNT ) { cout << counter << endl; ++counter; } cout << endl; // Post Increment within body of loop cout << "\nPost Increment within body of loop" << endl; counter = 1; while ( counter <= COUNT ) { cout << counter << endl; counter++; } cout << endl; // Post Increment within loop condition cout << "\nPost Increment within loop condition" << endl; counter = 1; while ( counter++ <= COUNT ) { cout << counter << endl; } cout << endl; // Pre Increment within loop condition cout << "\nPre Increment within loop condition" << endl; counter = 1; while ( ++counter <= COUNT ) { // repetition condition cout << counter << endl; } return 0; }