hello!could not find the mistake in this program....please help!
Code:
//cpp program to check whether a number is palindrome or not
#include<iostream.h>
#include<conio.h>
//the class
class palindrome
{
public:
int a[20];
int n;
int num;
int compare(int [],int);
};
//function to compare the same array from backwards and from forward direction
//if the comparison yields both the arrays to be same then return 1 else
//return 0
int palindrome::compare(int a[],int n)
{
int flag;
for(int i=0,j=n-1;i<n/2;i++,j--)
{
if(a[i]==a[j])
{
flag=1;
}
else
{
flag=0;
{
}
return(flag);
}
void main()
{
palindrome p1;
cout<<"\n Enter number";
cin>>p1.num;
int r;
int i=0;
//code to place the digits of the number into an array
while(p1.num>0)
{
r=p1.num%10;
p1.a[i++]=r;
p1.num/=10;
}
p1.n=i;
if(p1.compare(p1.a,p1.n)==1)cout<<"\n Number is palindrome";
else cout<<"\n Number is not palindrome";
getch();
}