i’m posting my code for is palindrome using recursion.
can you help with what should be the termination condition for thisrecursive program?
#include
using namespace std;
int check(string s, int i, int j){
if(s[i]!=s[j])
return 0;
else if(s[i]==s[j]){
check(s,i+1,j-1);
}
return 1;
}
int main(){
string s;
cin>>s;
int n;
n= s.length();
if(n==0 || n==1)
return true;
int m,i=0,j=n-1;
m=check(s,i,j);
if(m==1)
cout<<"true"<<endl;
else
cout<<"false"<<endl;
}
this is my code.