C Program to check whether it is a palindrome or not

The following C Program code checks whether the entered number is a palindrome or not.


SOURCE CODE
#include<stdio.h>
int main()
{
int n,rev=0,copy;
printf("Enter the number to check: ");
scanf("%d",&n);
copy=n;
while(n!=0)
{
rev=(rev*10)+(n%10);
n=n/10;
}
if(rev==copy)
{
printf("The number is a palindrome");
}
else
{
printf("It is not a palindrome");
}
getch();
return(0);
}
view raw gistfile1.txt hosted with ❤ by GitHub



Comments