/* testrep7.cpp CIS 150 6/10/2008 David Klick Demonstration of continue within a loop. Be careful with continue. It can easily cause infinite loops with while and do/while loops. */ #include using std::cin; using std::cout; void cont(); int main() { int ctr; // loop counter // display numbers from 1 to 10, but skip 7 for (ctr=1; ctr<=10; ctr++) { if (ctr == 7) continue; cout << ctr << " "; } cout << '\n'; 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 8 9 10 */