Recursive program to check if number is palindrome or not | Recursive C ++ program to check if the number is palindrome or not ; recursive function that returns the reverse of digits ; base case ; stores the reverse of a number ; Driver Code
#include <bits/stdc++.h> NEW_LINE using namespace std ; int rev ( int n , int temp ) { if ( n == 0 ) return temp ; temp = ( temp * 10 ) + ( n % 10 ) ; return rev ( n / 10 , temp ) ; } int main ( ) { int n = 121 ; int temp = rev ( n , 0 ) ; if ( temp == n ) cout << " yes " << endl ; else cout << " no " << endl ; return 0 ; }