Thursday, 2 January 2014

Palindrom Number

/*
Q17.    Write a program to check whether a number is palindrom or not.
*/
#include<stdio.h>

main()
{
    int num,temp,flag=0,rev=0;   
    printf("\nEnter a number=");
    scanf("%d",&num);
    temp=num;
    while(num)
    {
        rev=rev*10+num%10;
        num=num/10;
    }           
    if(rev==temp)
        printf("\n%d is a palindrome number",temp);
    else
        printf("\n%d is not a palindrome number",temp);           
}

No comments:

Post a Comment