Advertisement
borsha06

Pallindrome.cpp

Sep 6th, 2018
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.45 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int recursion(int num, int rem)
  5. {
  6.  
  7.     if(num == 0)
  8.     {
  9.         return rem;
  10.     }
  11.     rem = rem *10 + (num % 10);
  12.     return recursion(num/10,rem);
  13. }
  14. int main()
  15. {
  16.     int n;
  17.     cin>>n;
  18.     //cout<<recursion(n,0)<<endl;
  19.     if(recursion(n,0) == n)
  20.     {
  21.         cout<<"pallindrome number"<<endl;
  22.     }
  23.     else
  24.     {
  25.         cout<<"not a pallindrome number"<<endl;
  26.     }
  27.     return 0;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement