A number is called palindrome, if it reads the same on reading from both left and right. Thus, 121 is a palindrome, but 123 is not. Because, on reading from the right, it is 321 and not 123. The steps followed are, get the number to be checked. reverse the number. compare with the given number. conclude. The program would be as follows. The Program /palindrome 25/08/2013 #include<conio.h> #include<iostream.h> class dom { int dgt,dum; int flag; public: void get() { clrscr(); cout<<"enter the digit:"; cin>>dgt; dum=dgt; flag=0; } void check(); void disp() { if (flag==1) cout<<endl<<"palindrome"; else cout<<endl<<"not palindrome"; } }; void dom::check() { flag=0; int sum=0,w; while (dum!=0) { w=dum%10; sum=sum*10+w; dum=dum/10; } cout<<"reversed:"<<sum; if (sum==dgt) flag=1; }; void main() { clrscr(); dom obj; obj.get(); obj.check...
Vajahath Ahmed's personal blog.