/* testrep6.cpp CIS 150 6/7/2005 David Klick Demonstration of break within a loop. */ #include using std::cout; int main(void) { int ctr; // loop counter // display numbers from 1 to 10, // but stop if 7 is encountered for (ctr=1; ctr<=10; ctr++) { if (ctr == 7) break; cout << ctr << " "; } cout << '\n'; return 0; } /* Sample output: 1 2 3 4 5 6 */