Program:
#include<stdio.h>
int main()
{
int n,rev=0,rem,temp;
printf("Enter number: ");
scanf("%d",&n);
temp=n;
while(n>0)
{
rem=n%10; //separate the digit
rev=(rev*10)+rem; //reverse of number
n=n/10;
}
if(temp==rev)
{
printf("Palindrome number");
}
else
{
printf("Not a Palindrome number");
}
return 0;
}
Output:
#include<stdio.h>
int main()
{
int n,rev=0,rem,temp;
printf("Enter number: ");
scanf("%d",&n);
temp=n;
while(n>0)
{
rem=n%10; //separate the digit
rev=(rev*10)+rem; //reverse of number
n=n/10;
}
if(temp==rev)
{
printf("Palindrome number");
}
else
{
printf("Not a Palindrome number");
}
return 0;
}
Output:
No comments:
Post a Comment