fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6. int n, num, digit, rev = 0;
  7.  
  8. cout << "Enter a positive number: ";
  9. cin >> num;
  10.  
  11. n = num;
  12.  
  13. do
  14. {
  15. digit = num % 10;
  16. rev = (rev * 10) + digit;
  17. num = num / 10;
  18. } while (num != 0);
  19.  
  20. cout << " The reverse of the number is: " << rev << endl;
  21.  
  22. if (n == rev)
  23. cout << " The number is a palindrome";
  24. else
  25. cout << " The number is not a palindrome";
  26.  
  27. return 0;
  28. }
Success #stdin #stdout 0s 16064KB
stdin
Standard input is empty
stdout
Enter a positive number:  The reverse of the number is: 15111
 The number is not a palindrome