1  #include <iostream>
  2  #include <string>
  3  using namespace std;
  4  
  5  bool isPalindrome(const string& s)
  6  {
  7    if (s.size() <= 1) // Base case
  8      return true;
  9    else if (s[0] != s[s.size() - 1]) // Base case
 10      return false;
 11    else
 12      return isPalindrome(s.substr(1, s.size() - 2));
 13  }
 14  
 15  int main()
 16  {
 17    cout << "Enter a string: ";
 18    string s;
 19    getline(cin, s);
 20  
 21    if (isPalindrome(s))
 22      cout << s << " is a palindrome" << endl;
 23    else
 24      cout << s << " is not a palindrome" << endl;
 25  
 26    return 0;
 27  }