Not able to get the correct output < Is Palindrome `

#include

using namespace std;

bool IsPalindrome(int A[],int n)
{
if (n==0|| n==1)
{
return true;
}
else
{
for ( int start = 0; start < n; start++)
{
if(A[start]!=A[n])
{
return false;
}

        n--;
    }
    return true;
}

}

int main()
{
int num;
cin>>num;
int Array[num];
for (int i = 0; i < num; i++)
{
cin>>Array[i];
}

cout<<IsPalindrome(Array,num);
return 0;    

}

Hey @rprahulpal03

#include<iostream>

using namespace std;

bool IsPalindrome(int A[],int n)
{
    if (n==0|| n==1)
    {
        return true;
    }
    else
    {   
        for ( int start = 0; start < n; start++)
        {
            if(A[start]!=A[n-1]) //n-1 here
            {
                return false;
            }
            n--;
        }
        return true;
    }
}

int main()
{
    int num;
    cin>>num;
    int Array[num];
    for (int i = 0; i < num; i++)
    {
        cin>>Array[i];
    }

    cout<<(IsPalindrome(Array,num)?"true":"false"); //updated this
    return 0;    
}

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.