Check whether a number is a palindrome or not with C
#include <stdio.h>
int main()
{
int n, num, reverse = 0;
printf("Enter any number to check palindrome: ");
scanf("%d", &n);
num = n;
while (n != 0)
{
reverse = (reverse * 10) + (n % 10);
n /= 10;
}
if (reverse == num)
{
printf("%d is palindrome.", num);
}
else
{
printf("%d is not palindrome.", num);
}
return 0;
}
Output:-
Enter any number to check palindrome : 1221
1221 is palindrome.
0 Comments