1
0

forstr1.cpp 372 B

123456789101112131415161718
  1. // forstr1.cpp -- using for with a string
  2. #include <iostream>
  3. #include <string>
  4. int main()
  5. {
  6. using namespace std;
  7. cout << "Enter a word: ";
  8. string word;
  9. cin >> word;
  10. // display letters in reverse order
  11. for (int i = word.size() - 1; i >= 0; i--)
  12. cout << word[i];
  13. cout << "\nBye.\n";
  14. // cin.get();
  15. // cin.get();
  16. return 0;
  17. }