Program to calculate whether a given number is palindrome or not.
Program Code:
#include<stdio.h>
#include<conio.h>
int main()
{
int temp,rev=0,num,remainder ;
clrscr();
printf("Enter the number\n");
scanf("%d",&num);
temp=num;
while(num!=0) //Reversing the number
{
remainder = num%10;
num = num/10;
rev = rev*10+ remainder;
}
printf("The reverse number is %d",rev);
if(rev == temp)
printf("\n%d is a palindrome",temp);
else
printf("\n%d is not a palindrome", temp);
getch();
}
Output:
Enter the number
1001
The reverse number is 1001
1001 is a palindrome
Post A Comment:
0 comments: