A palindrome is a word that is spelled exactly the same backwards as forwards(e.g level)write a recursive function that returns true if the word given to it is a palindrome
#include <iostream>
#include <string>
using namespace std;
void is_palindrome(string s);
int main()
{
string str;
cout<<"Please enter a string : "<<endl;
cin>>str;
is_palindrome(str);
return 0;
}
void is_palindrome(string s)
{
if (s.length()>0)
{
is_palindrome(s.substr(1,s.length()-1));
cout<<s[0];
}
}
i just can use the recursive to cout a backwards of string
but i don't know how to save it to a variable and compare it..
Pls help.... Thx...