Sunday, 2 October 2011

Palindrome number in C

/* A Palindrome number is a number which on reversing prodeuce the same number. E.g. 121 on reversing 121
second example 12321 on reversing produces 12321. */


#include<stdio.h>
#include<conio.h>
void main()
{
float n,s=0;
int r=0,i=0;
clrscr();
printf("Number: ");
scanf("%f",&n);
for(i=n;i>=1;i=i/10)
{
r=i%10;
s=s*10+r;
}
if(s==n)
printf("Palindrome");
else
printf("Not Palindrome");
getch();

No comments:

Post a Comment