Palindrome Number in C, Java, and Python

How to Determine?


A palindrome is a word, phrase, number, or sequence of characters that reads the same both forward and backward when reversed. Eg: dad, 101, etc.

Problem Statement

Given a positive integer, the task is to determine whether the number is a palindrome or not.

Input 1: 146541  Output: False Input 2: 1221 Output: True


1. Take user's input. 2. Declare a variable reverseNum=0. 3. Now, make a while loop until the original number > 0.

Algorithm to Check Palindrome Number

4. In every loop, get last digit of number and add that digit at end of reverseNum and then divide original number by 10.  reverseNum = reverseNum * 10 + (number % 10)   5. Lastly, check if original number = reverseNum.

How to implement this approach in different programming languages?