//Note: If you are not using Borland or Turbo C then add the following line after header files :
//using namespace std;
#include<conio.h>
#include<iostream.h>
class palindrome
{
int copy,n,sum,rem; // copy=copy of no , n=number
public:
void accept()
{
cout<<"Enter the number:";
cin>>n;
copy=n;
}
void check()
{
sum=0;
while(n!=0)
{
rem=n%10;
sum=sum*10+rem;
n=n/10;
}
if(copy==sum)
cout<<"\nThe number is palindrome : "<<sum;
else
cout<<"\nThe number is not palindrome : "<<sum;
}
};
void main()
{
palindrome obj; //object created
obj.accept();
obj.check();
getch();
}
0 Comments