/* testrep8.cpp CIS 150 6/10/2008 David Klick Demonstration of a sentinel-controlled loop. */ #include using std::cout; using std::cin; void cont(); int main() { int num; // variable for user input num = 0; // make sure variable not set to sentinel value do { cout << "Enter integer (-999 to exit): "; cin >> num; } while (num != -999); 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: Enter integer (-999 to exit): 54 Enter integer (-999 to exit): -200 Enter integer (-999 to exit): -999 */