Guest User

Untitled

a guest
May 21st, 2018
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. string word;
  8. bool palindrome;
  9.  
  10. cout << "Enter a word: ";
  11. cin >> word;
  12.  
  13. for (int x=0; x < word.length()-1; x++)
  14. {
  15. if (tolower(word[x]) != tolower(word[word.length()-(x+1)]))
  16. {
  17. palindrome = false;
  18. break;
  19. }
  20. else
  21. palindrome = true;
  22. }
  23.  
  24. if (palindrome)
  25. cout << "It is a palindrome";
  26. else
  27. cout << "It is a not palindrome";
  28.  
  29. return 0;
  30. }
Add Comment
Please, Sign In to add comment