#include<math.h>
void main()
{
int num,cnt,rev=0,temp;
clrscr();
printf("\n Enter the number\n");
scanf("%d",&num);
temp=num;
cnt=log10(num)+1;
printf("\n the no of digits in a given number is %d",cnt);
cnt=cnt-1;
while(num!=0)
{
rev=rev+((pow(10,cnt))*(num%10));
cnt=cnt-1;
num=num/10;
}
printf("\n the digits in reverse order is %d",rev);
if(temp==rev)
printf("\nThe given number is a palindrome");
else
printf("\nThe given number is not a palindrome");
getch();
}
Responses
0 Respones to "how to check the given number is a palindrome (using pow and log in a easy way)"
Post a Comment