C Program Check Palindrome Number

By | March 11, 2020

C Program Check Palindrome Number

#include <stdio.h>
int main()
{
int n, reverseNum, lastDigit, num;
printf("Enter a number : ");
scanf("%d",&num);
n = num;
reverseNum = 0;
while(n > 0)
{
lastDigit = n % 10;
reverseNum = (reverseNum * 10) + lastDigit;
n = n / 10;
}
if(num == reverseNum)
printf("\n%d is a Palindrome number", num);
else
printf("\n%d is not a Palindrome number", num);
return 0;
}

OUTPUT

Enter a number : 525

525 is a Palindrome number

 

 Output 2 

Enter a number : 679

679 is not a Palindrome number

 

Loading

Leave a Reply

Your email address will not be published. Required fields are marked *