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:
Palindrome for Words
Comment bellow for your Query and Feedback
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#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();
}
Palindrome for Words
Comment bellow for your Query and Feedback
Categories:
c program
1 comments:
thanks
Post a Comment