/* testrep2.cpp CIS 150 6/10/2008 David Klick Demonstration of while loop. */ #include using syd::cin; using std::cout; void cont(); int main() { int ctr; // first count up by 1 ctr = 1; while (ctr<=10) { cout << ctr << " "; ctr++; } cout << '\n'; // then count down by 1 ctr = 10; while (ctr>=1) { cout << ctr << " "; ctr--; } cont(); return 0; } void cont() { if (cin.rdbuf()->sungetc() != -1 && cin.get() != '\n') cin.ignore(80,'\n'); cout << "Press enter to continue..."; cin.get(); } /* Sample output: 1 2 3 4 5 6 7 8 9 10 10 9 8 7 6 5 4 3 2 1 */