isPalindrome Ques. from strings part

what’s wrong in the below code ?

#include
using namespace std;

bool isPalindrome(int arr[],int size,int low, int high)
{
//base condition
if(size == 0 || size == 1)
return true;

//recursion call and self work
if(arr[low] == arr[high])
isPalindrome(arr,size,low+1,high-1);
else
return false;

}

int main()
{
int n,x,i;
cin>>n;
int arr[n];
while(n–)
{
cin>>x;
arr[i]=x;
}

if(isPalindrome(arr,n,0,n-1))
cout<<"true";
else
cout<<"false";

return 0;

}

@rc191929_548b9538c8b289e0
there are 2 errors after taking input every time your value of n becomes 0 and you are taking all inputs in one index intead of this used for loop here
and in recursion
make a condition if low>=high return true
and add a return work in your if statement
it will work fine if your dout sill exists let me know and if clear feel free to ask

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.