0

How to make a program for string palindrome in c++

we have to enter a word and then check whether the word is palindrome or not in c++

27th Feb 2017, 6:58 PM
Utkarsh Sharma
Utkarsh Sharma - avatar
1 Answer
+ 2
#include <iostream> using namespace std; bool isPalindrome(string s) { for(int i = 0; i < s.size() / 2; ++i) if(s[i] != s[s.size() - 1 - i]) return false; return true; } int main() { string s; cin >> s; cout << (isPalindrome(s)? "It's palindrome" : "It isn't palindrome"); }
27th Feb 2017, 7:17 PM
SUPER_S
SUPER_S - avatar