#include<stdio.h>
int main()
{
int n,num;
printf("Enter a number\n");
scanf("%d",&n);
int reversed_number=0,rem;
num=n;
while(n!=0)
{
rem=n%10;
reversed_number=reversed_number*10+rem;
n=n/10;
}
if(reversed_number==num)
{
printf("%d is palindrome \n",num);
}
else
{
printf("%d is not a palindrome\n",num);
}
}
Output:
int main()
{
int n,num;
printf("Enter a number\n");
scanf("%d",&n);
int reversed_number=0,rem;
num=n;
while(n!=0)
{
rem=n%10;
reversed_number=reversed_number*10+rem;
n=n/10;
}
if(reversed_number==num)
{
printf("%d is palindrome \n",num);
}
else
{
printf("%d is not a palindrome\n",num);
}
}
Output:
Comments
Post a Comment