Write C++ program to check whether a number is palindrome or not


techstudy.org

HP 15 Core i3 7th gen Laptop(4GB, 1TB HDD, Windows 10) | Rs. 31,490

Introduction

I have used CodeBlocks compiler for debugging purpose. But you can use any C++ programming language compiler as per your availability.


  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. int num, i, rev;
  8.  
  9. //Reading a number from user
  10. cout<<"Enter any number:";
  11. cin>>num;
  12.  
  13. rev = num;
  14. for(i=0; num>0; num=num/10)
  15. {
  16. i = i * 10;
  17. i = i + (num%10);
  18. }
  19. //Checking if reverse number is equal to original num or not.
  20. if(rev == i)
  21. cout<< rev << " is a Palindrome Number.";
  22. else
  23. cout<< rev << " is not a Palindrome Number.";
  24.  
  25. return 0;
  26. }
  27.  

Result

C++ language techstudy.org

     





Related Topics




Popular Posts