Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- int main()
- {
- string word;
- bool palindrome;
- cout << "Enter a word: ";
- cin >> word;
- for (int x=0; x < word.length()-1; x++)
- {
- if (tolower(word[x]) != tolower(word[word.length()-(x+1)]))
- {
- palindrome = false;
- break;
- }
- else
- palindrome = true;
- }
- if (palindrome)
- cout << "It is a palindrome";
- else
- cout << "It is a not palindrome";
- return 0;
- }
Add Comment
Please, Sign In to add comment