Thursday, November 11, 2010

C Program to check number is palindrome or not



C Program Code


//Check number is palindrome of not
#include "stdio.h"
#include "conio.h"
void main()
{
int num,rev=0,m,r;
clrscr();
printf("enter any number");
scanf("%d",&num);
m=num;
while(num>0)
{
r=num%10;
rev=rev*10+r;
num=num/10;
}
if(rev==m)
printf("given number is palindrome");
else
printf("given number is not palindrome");
getch();
}

Input/Output


enter any number 121
given number is palindrome

enter any number 423
given number is not palindrome

What is Palindrome No?


when we read a number. If backward read is as same as forward read then number is palindrome.

7 comments:

Rohit said...

It helped me in my exam..thanx:-)

peddaiahgari said...
This comment has been removed by the author.
peddaiahgari said...

it helped in lab viva thanks admin

ygshinkar said...

Nice Explain

Pinky said...

can u please let me know to write a pl/sql program for it

Unknown said...

give the explanation for this particular program #include Int main() { Int a[5]={10,20,30,40,50}; Int *ptr=(int *)(&a+1); Printf(“%d %d”,*(a+1),*(ptr-1)); }

Joel J. George said...

good gob but ,Check number is palindrome of not... Check number is palindrome or not? which one ..

Post a Comment

Dont SPAM