Below is the code to Check whether the given number is palindrome or not:
We will start off by taking an input and store it in ‘n’ and make a duplicate of it in ‘temp’. We will also initialize another variable ‘rev’ to 0.
Then, we will enter a while loop which will go on until ‘n’ becomes 0.
Inside the loop, we will start off by dividing ‘n’ with 10 and then store the remainder in ‘dig’.
Then, we will multiply ‘rev’ with 10 and then add ‘dig’ to it. This result will be stored back in ‘rev’.
Going ahead, we will divide ‘n’ by 10 and store the result back in ‘n’
Once the for loop ends, we will compare the values of ‘rev’ and ‘temp’. If they are equal, we will print ‘The number is a palindrome’, else we will print ‘The number isn’t a palindrome’.