Pages

Ads 468x60px

Saturday, 2 June 2012

C Program For PALINDROME OF NUMBER


C Program For PALINDROME OF NUMBER



Palindrome number in c: A palindrome number is a number such that if we
 reverse it, it will not change. For example some palindrome numbers examples 
are 121, 212, 12321, -454. To check whether a number is palindrome or not first
 we reverse it and then compare the number obtained with the original, if both are
 same then number is palindrome otherwise not. 


Get the number from user.
Reverse it.
Compare it with the number entered by the user.
If both are same then print palindrome number
Else print not a palindrome number.

CODE:
#include<stdio.h>
#include<conio.h>
void main()
{
int k,n,t,s=0;
clrscr();
printf("Enter the n value:");
scanf("%d",&k);
n=k;
while(n>0)
{
t=n%10;
s=s*10+t;
n=n/10;
}
if(k==s)
{
printf("given %d number is palindrome",k);
}
else
{
printf("not palindrome");
}
getch();
}

0 comments:

Post a Comment

Total Pageviews