Skip to main content

C Program to check Pallindrome Number

C Program to check Pallindrome Number


// Program to check Pallindrome as  example - 1441



#include <stdio.h>

int main()

{

    int n, reverseInt = 0, remainder, originalIn;



    printf("Enter an integer: ");

    scanf("%d", &n);



    originalIn = n;



    // reversed integer is stored in variable

    while( n!=0 )

    {

        remainder = n%10;

        reverseInt = reverseInt*10 + remainder;

        n /= 10;

    }



    // palindrome if orignalInteger and reverseInt are equal

    if (originalIn == reverseInt)

        printf("%d is a palindrome.", originalIn);

    else

        printf("%d is not a palindrome.", originalIn);

 

    return 0;

}