ifelse.cpp 531 B

12345678910111213141516171819202122
  1. // ifelse.cpp -- using the if else statement
  2. #include <iostream>
  3. int main()
  4. {
  5. char ch;
  6. std::cout << "Type, and I shall repeat.\n";
  7. std::cin.get(ch);
  8. while (ch != '.')
  9. {
  10. if (ch == '\n')
  11. std::cout << ch; // done if newline
  12. else
  13. std::cout << ++ch; // done otherwise
  14. std::cin.get(ch);
  15. }
  16. // try ch + 1 instead of ++ch for interesting effect
  17. std::cout << "\nPlease excuse the slight confusion.\n";
  18. // std::cin.get();
  19. // std::cin.get();
  20. return 0;
  21. }