for ex- Number is 121 then it's reverse is 121 so both are same this means it is
a palindrome number. Other numbers are 11211 , 1551, 17871, etc.
So, this program will check if the reverse of the number entered is same as
the number entered if it's same then, it is palindrome otherwise not.
Program
#include <stdio.h>
#include <conio.h>
void main()
{
int n,
temp, rev=0, rem;
printf("Enter the number: ");
scanf("%d",&n);
temp=n;
while(n>0)
{
rem=n%10;
rev=rev*10+rem;
n=n/10;
}
if(rev == temp)
{
printf("Number is palindrome");
}
else
{
printf("Number is not palindrome");
}
}
Output:
Post a Comment