Palindrome Program in C - Palindrome in C



 c program to check palindrome number

Learn C - C tutorial - c program to check palindrome number - C examples - C programs

Palindrome number in C

  • If we reverse a numbers, the number remains the same it is said to be the palindrome number.
  • For example, some palindrome numbers examples are 121, 212, 12321, -454.
  • To check a number is a palindrome or not first we reverse it and then compare the number obtained with the original, if both are same then the number is palindrome otherwise not.

Sample Code


#include <stdio.h>
int main()
{
    int n=7397, reverse = 0, temp;
    temp = n;
    while( temp != 0 )
    {
        reverse = reverse * 10;
        reverse = reverse + temp%10;
        temp = temp/10;
    }
    if ( n == reverse )
        printf("%d is a palindrome number.\n",n);
    else
        printf("%d is not a palindrome number.\n",n);
    return 0;
}

Output

7397 is not a palindrome number


View More Quick Examples


Related Searches to Palindrome Program in C - Palindrome in C