A palindromic number is a number that remains the same when its digits are reversed. For example, 16461. Write a program that prompts the user to input a number and determine whether the number is palindrome or not.
#include <stdio.h>
int main()
{
int number, temp, remainder, reverse = 0;
printf("Enter a number :");
scanf("%d", &number);
temp = number;
while (temp > 0)
{
remainder = temp % 10;
reverse = reverse * 10 + remainder;
temp /= 10;
}
if (reverse == number)
{
printf("The number is palindrome.");
}
else
{
printf("The number is not palindrome.");
}
return 0;
}
Enter a number :16461
The number is palindrome.