program to check which number is palindrome or not in c-programming?
In this program, we will getting an input from the user and check whether a number is
palindrome or not .
First we now about what is palindrome ?
- An integer is a palindrome if the reverse of that number is equal to the its original number.
#include<stdio.h>
#include<conio.h>
void main()
{
int n,p,x,y=0;
printf("enter the number");
scanf("%d",&n);
p=n;
while(n!=0)
{
x=n%10;
y=y*10+x;
n=n/10;
}
if(y==p)
printf("the number is plaindrome %d",y);
else
printf("the number not plaindrome");
getch();
}
#include<conio.h>
void main()
{
int n,p,x,y=0;
printf("enter the number");
scanf("%d",&n);
p=n;
while(n!=0)
{
x=n%10;
y=y*10+x;
n=n/10;
}
if(y==p)
printf("the number is plaindrome %d",y);
else
printf("the number not plaindrome");
getch();
}
output:- n=121
the number is plaindrome.
For more c-programming:-
1.c-program to calculate the sum of the digits of three digits numbers
2.c-program to calculate the factorial of a number.
3.c-program to check Armstrong number
No comments:
Post a Comment