Program To Check Number Is Palindrome Or Not Using Function - C Program

Program To Check Number Is Palindrome Or Not Using Function

A palindrome number is a number that is same after reverse. For example 545, 171 are the palindrome

#include <stdio.h>
int isPalindrome(int num);
int main()
{
    int num,result;
    printf("Enter the number:");
    scanf("%d",&num);
    result = isPalindrome(num);
    if(result==1)
        printf("%d is Palindrome number",num);
    else
        printf("%d is not an Palindrome number",num);
    return 0;
}
int isPalindrome(int num)
{
    int rnum=0,r,n;
    n=num;
    while(n>0)
    {
        r=n%10;
        rnum=rnum*10+r;
        n=n/10;
    }
    if(rnum==num)
        return 1;
    else
        return 0;
}

Output - Program To Check Number Is Palindrome Or Not Using Function

Enter the number:151   
151 is Palindrome number 
Compile and Run Online