Number is palindrome or not
C program to check whether a number is palindrome or not.
A palindrome number is a number that is same after reverse. For example, 121, 272, 34643, 4554 are palindrome numbers.
To check if a number is palindrome or not, we reverse it and compare it with the original number. If both are the same, it's a palindrome otherwise not.
s
To check if a number is palindrome or not, we reverse it and compare it with the original number. If both are the same, it's a palindrome otherwise not.
Program
#include<stdio.h>
#include<conio.h>
void main()
{
int num, rev_num, orig_num, rem;
printf("Enter the number\t:");
scanf("%d",&num);
orig_num = num;
rev_num = 0;
while(num != 0)
{
rem = num % 10;
rev_num = rev_num * 10 + rem;
num = num / 10;
}
if(orig_num == rev_num)
printf("Number entered is palindrome");
else
printf("Number entered is not a palindrome");
getch();
}
Output
********** Run1 **********
Enter the number :456
Number entered is not a palindrome
********** Run2 **********
Enter the number :1221
Number entered is palindrome