How to write c++ palindrom number Program with source code
121=121 is palindrom.
167=761 is not a palindrome number.
int pali(int);
void main()
{
int n,a;
clrscr();
cout<<"\n enter the number=";
cin>>n;
a=palindrom(n);
if(n==a)
cout<<"\n number is palindrom";
else
cout<<"\n number is not palindrom";
getch();
}
int palindrom(int x)
{
int r,sum=0;
while(x!=0)
{
r=x%10;
sum=sum*10+r;
x/=10;
}
return(sum);
}
121=121 is palindrom.
167=761 is not a palindrome number.
int pali(int);
void main()
{
int n,a;
clrscr();
cout<<"\n enter the number=";
cin>>n;
a=palindrom(n);
if(n==a)
cout<<"\n number is palindrom";
else
cout<<"\n number is not palindrom";
getch();
}
int palindrom(int x)
{
int r,sum=0;
while(x!=0)
{
r=x%10;
sum=sum*10+r;
x/=10;
}
return(sum);
}
0 comments: