Apr 22, 2013

C program to find a given number is pallindrome or not


#include<stdio.h>
#include<conio.h>
void main()
{
int no,d,sc,rev=0;
clrscr();
printf("\nenter no(chek for pallinrome)=");
scanf("%d",&no);
sc=no; //second copy of no
while(no>0)
{
d=no%10;
rev=rev*10+d;
no=no/10;
}
if(rev==sc)
{
printf("\n \n %d is pallindrome",sc);
}
else
{
printf("\n \n%d is not pallindrome",sc);
}
getch();
}

OUTPUT


enter no(chek for pallinrome)=121
121 is palindrome
enter no(chek for pallinrome)=132
132 is not pallindrome


0 comments:

Post a Comment