Determine if a given number is a palindrome or not

Write a program to determine if a given number is a palindrome or not. A palindromic number is a number that remains the same when its digits are reversed. Like 16461, for example, it is “symmetrical”.


We know that even if we reverse a palindrome number, it’s value will not change. This forms the idea behind proposed solutions. If the given number is equal to its reverse, then the number is palindrome else it is not palindrome number.

Iterative version –


Download   Run Code


Recursive version (in C++) –


Download   Run Code


We can also easily merge reverse() and isPalindrome() functions into one.


Download   Run Code

Please note that use of static variables is not recommended. Instead, we can pass the variables as argument to the isPalindrome() function.

1 Star2 Stars3 Stars4 Stars5 Stars (1 votes, average: 5.00 out of 5)


Thanks for reading.

Please use our online compiler to post code in comments. To contribute, get in touch with us.
Like us? Please spread the word and help us grow. Happy coding 🙂

Leave a Reply

Notify of