Advertisement
Shohag_Rana_Hriday

palindrome number

Feb 5th, 2020
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. #include<iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6.  
  7. int n,temp,sum=0,r,count=0,i=1;
  8.  
  9. cin>>n;
  10. temp=n;
  11. while(temp!=0)
  12. {
  13. // sum = 0;
  14. r = temp % 10;
  15. sum = sum*10 + r;
  16. temp = temp/10;
  17.  
  18. count++;
  19.  
  20. cout<<i++<<"th "<<"digit:"<<r<<"\n";
  21.  
  22. }
  23. cout<<"sum:"<<sum<<endl;
  24. if(n==sum)
  25. {
  26. cout<<"palindrome\n";
  27.  
  28. }
  29.  
  30. else {
  31. cout<<"not palindrome\n";
  32. }
  33.  
  34. cout<<"total digit"<<count;
  35.  
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement