Search Your C Program

Thursday 9 February 2012

Program to find whether a number is palindrome or not.

#include<stdio.h>
#include<conio.h>
void main()
{
                long rev = 0,n, num , rem;
                clrscr();
                printf("\n Enter the number");
                scanf("%ld",&num);
                n=num;
                while(n>0)
                {
                              rem= n % 10;
                              n=n/10; 
                              rev=rev*10 + rem;
                }
                
                if(rev = = num)
                             printf(" \n Number %ld is palindrome", num);
                else
                             printf(" \n Number %ld is not palindrome", num);                    
                getch();
}               

No comments:

Post a Comment