SabirSazzad

Palindrome

Mar 17th, 2017
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.62 KB | None | 0 0
  1. #include<iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6.     int num1,num2,Count=0,rem,revNum=0,n;
  7.     cout << "Input 1st limit: ";
  8.     cin >> num1;
  9.     cout << "Input last limit: ";
  10.     cin >> num2;
  11.  
  12.     for(int i=num1; i<= num2; i++)
  13.     {
  14.         revNum=0;
  15.         n = num1;
  16.         while(n != 0)
  17.         {
  18.             rem = n%10;
  19.             revNum = revNum*10 + rem;
  20.             n /= 10;
  21.         }
  22.         if(num1==revNum)
  23.         {
  24.             cout << "Palindrome num: "<< revNum <<endl;
  25.             Count++;
  26.         }
  27.         num1++;
  28.     }
  29.     cout << "Total palindrome number: " << Count <<endl;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment