/* * * * * * * * * * * * * * * * * * * * * Name: Nathanael Paul Userid: nrpaul Section #: 0 Date: October 2, 2000 Program #: 50 Program Description: Demonstrates the use of Do loops and For loops by printing each value from 1 to 100 * * * * * * * * * * * * * * * * * * * * */ #include // use of cin, cout, endl using namespace std; /* * * * * * * * * * * * * * * * * * * * * Function: int main() Parameters: none Description: See program description at top * * * * * * * * * * * * * * * * * * * * */ int main() { int i = 1; cout << "Entering while loop..."; while(i < 101) { if(i % 10 != 0) { cout << i << " "; } else { cout << i << endl; } // equivalent to i++; or ++i; or i = i + 1; i += 1; } cout << "Value of i after while loop: " << i << endl; cout << "Enter a value of i greater than 101: "; cin >> i; cout << "Entering do loop..." << endl; do { if(i % 10 != 0) { cout << i << " "; } else { cout << i << endl; } if (i > 101) { cout << endl << "Enter a value for i below 20: "; cin >> i; } } while (i++ < 50); cout << "Value of i after do loop: " << i << endl; cout << "Enter another value of i below 250: "; cin >> i; for(int j = 175; j < i && i < 400; j++, i++) { cout << "j: " << j << " i: " << i << endl; } return 0; }