C Program to Check Whether a Number is Palindrome or Not

Step Execution

#include <stdio.h>
int main()
int n, reversedN = 0, remainder, originalN;
printf("Enter an integer: ");
scanf("%d", &n);
originalN = n;
while (n != 0) {
remainder = n % 10;
reversedN = reversedN * 10 + remainder;
n /= 10;
}
if (originalN == reversedN)
printf("%d is a palindrome.", originalN);
else
printf("%d is not a palindrome.", originalN);
return 0;
}

Initialize



Output

Yes, The given number is Palindrome!

No, The given number is not a Palindrome!