or.cpp 686 B

12345678910111213141516171819202122
  1. // or.cpp -- using the logical OR operator
  2. #include <iostream>
  3. int main()
  4. {
  5. using namespace std;
  6. cout << "This program may reformat your hard disk\n"
  7. "and destroy all your data.\n"
  8. "Do you wish to continue? <y/n> ";
  9. char ch;
  10. cin >> ch;
  11. if (ch == 'y' || ch == 'Y') // y or Y
  12. cout << "You were warned!\a\a\n";
  13. else if (ch == 'n' || ch == 'N') // n or N
  14. cout << "A wise choice ... bye\n";
  15. else
  16. cout << "That wasn't a y or n! Apparently you "
  17. "can't follow\ninstructions, so "
  18. "I'll trash your disk anyway.\a\a\a\n";
  19. // cin.get();
  20. // cin.get();
  21. return 0;
  22. }