Is palindrome using recursion

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.

Hey @Mudit809 I tweaked your code a little.

  1. Your code was taking the input in a wrong format ,so I corrected that and used an int array A[] instead of the string to make the implementation easier .
  2. Now in your check() function you can use the termination condition if(i<n) return 1, because you reach this state if and only if the string was a palindrome .( Do some dry runs and you will know why).

This is your changed code https://ide.codingblocks.com/s/174855.
If you have any further queries please feel free to ask otherwise kindly mark the doubt as resolved.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.