/* testio2.cpp CIS 150 6/5/2008 David Klick This program demonstrates data validation using the if/else selection structure. */ #include using std::cout; using std::cin; void cont(); int main(void) { char ch; bool error = false; cout << "Enter the letter 'Y': "; cin >> ch; if (ch == 'Y' || ch == 'y') { cout << "Thank you\n"; } else { cout << "Invalid character entered\n"; error = true; } if (error) { cout << "Abnormal program termination\n"; } else { cout << "Normal program end\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(); }