===========================================================================
CODING
#include<all.h>
void main()
{
clrscr();
int n,m,a,sum,c,i,p=0,q,l;
cout<<"Enter number for checking for Palindrome: ";
cin>>n;
m=n;
l=n;
for(q=0;l!=0;q++)
{
l=l/10;
p=p+1;
}
for(i=0,sum=0,a=0;n!=0;i++,p=p-1)
{
a=n%10;
n=n/10;
sum=a*pow(10,p-1)+sum;
}
cout<<m<<" : "<<sum;
if(sum==m)
cout<<"\n\nTherefore, "<<m<<" is Plaindrome";
else
cout<<"\n\nTherefore, "<<m<<" is NOT a Palindrome";
getch();
}
CODING
#include<all.h>
void main()
{
clrscr();
int n,m,a,sum,c,i,p=0,q,l;
cout<<"Enter number for checking for Palindrome: ";
cin>>n;
m=n;
l=n;
for(q=0;l!=0;q++)
{
l=l/10;
p=p+1;
}
for(i=0,sum=0,a=0;n!=0;i++,p=p-1)
{
a=n%10;
n=n/10;
sum=a*pow(10,p-1)+sum;
}
cout<<m<<" : "<<sum;
if(sum==m)
cout<<"\n\nTherefore, "<<m<<" is Plaindrome";
else
cout<<"\n\nTherefore, "<<m<<" is NOT a Palindrome";
getch();
}
===========================================================================
No comments:
Post a Comment