Program to check palindrome number in C

WAP to check wheather the entered number is palindrome or not.
 ==> A palindromic number is a number that remains the same when its digits are reversed. Like 16461, 12321, 121 etc.

Code goes like this :
/* WAP to check weather the entered number is palindrome or not */
#include<stdio.h>
int main()
{
    int rem,rev=0,num,i,original;
    printf("Enter a number:");
    scanf("%d",&num);
    original=num;           // To compare the original number with reverse number
        while(num!=0)      //reverse number checking starts
    {
    rem=num%10;
    rev=rev*10+rem;
    num=num/10;
    }                     //reverse number checking ends
    if (original==rev)    //Comparing original & reverse number
    printf("\n Palindrome Number");
    else
    printf("\n Not Palindrome");
    return 0;
}

Output : 











Output1:












I have used Dev CPP to compile this program.
If you are using Turbo C++ IDE, then use conio.h in link section after stdio.h
and use getch(); to hold the output screen, just before the end of main function.
If you have any confusion regarding the program, please, comment below.
Happy Coding !
Thank you
Share on Google Plus

About Nepali Xoro

Interested in Information Technology, Spreading Knowledge for Nepalease IT Students."Loves Traveling", Listen Music and Surfing web.
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment