September 1, 2011

C Program to Find Palindrome of a Number

C Program to Find Palindrome of a Number
A Palindrome is a word, phrase, number or other sequence of units that can be read the same way in either direction.


for example:
in words:
pop
civic
level


in number:
121
1221
Sample Output:

Code:


/*www.mycfiles.com - Palindrome For Numbers */
#include<stdio.h>
#include<conio.h>
void main(){
int s=0,d,n,m;
clrscr();
printf("Enter The Figure :\n");
scanf("%d",&n);
m=n;
while(n!=0){
d=n%10;                 //This is the logic block
s=s*10+d;              // here the figure get reversed
n=n/10;


}
if(m==s)
printf("It's A Palindrome");             //In this block the comparison is performed
else                                    // between the reversed figure and the
printf("It's Not A Palindrome");       // original figure i.e n
getch();


}

Also Read
Palindrome for Words
Comment bellow for your Query and Feedback

Related Posts :



Categories:

1 comments:

Post a Comment

Twitter Delicious Facebook Digg Stumbleupon Favorites More

 
Related Posts with Thumbnails