write a program to check whether entered number is palindrome or not

Palindrome :A word or phrase that reads the same backward as forward.
A number is taken from user and then checks if the entered number is palindrome or not.


Select To use this code as it is.. select and copy paste this code into code.cpp file :)



  1. #include<iostream.h>
  2. #include<conio.h>
  3. void main()
  4. {
  5. clrscr();
  6. long int n,rev=0,m,num;
  7. cout<<"please enter a five digit no.: ";
  8. cin>>n;
  9. num=n;
  10. while(n>0)
  11. //Coding by: Snehil Khanor
  12. //http://WapCPP.blogspot.com
  13. {
  14. m=n%10;
  15. rev=rev*10+m;
  16. n=n/10;
  17. }
  18. cout<<rev<<endl;
  19. if (num==rev)
  20. cout<<"Number is a palindrome";
  21. else
  22. cout<<"Not a palindrome";
  23. getch();
  24. }

Check out this stream