Saturday, December 31, 2011

Find the number is palimdrome or not in 'C'

Example



#include<stdio.h>
#include<conio.h>
void main()
{
int i,n,pal=0,a,m;
clrscr();
printf("Enter the number:");
scanf("%d",&n);
m=n;
while(n>0)
{
   a=n%10;
   pal=(pal*10)+a;
   n=n/10;
}
if(m==pal)
{
printf("Given number is palimdrome");
}
else
{
printf("Given number is not palimdrome");
}
getch();
}
/*=======================================================================
OUTPUT
Enter the number:333
Given number is palimdrome
*/

No comments:

Post a Comment