Find the reverse of a number and check whether the number is a pallindrome or not using C
Hey guys once again welcome to the Decoders blog, I hope you all are doing well and today I'm present with another logic but this time with something different it is a C logic which will help us to check whether a number is pallindrome number or not using C and we'll also find out the reverse of that number.
#include<stdio.h>
int main()
{
int n,i,rev;
printf("Enter the value of n:");
scanf("%d",&n);
int str=n;
while(str>0)
{
i=str%10;
rev = rev*10+ i;
str=str/10;
}
printf("The reverse number is %d\n",rev);
if(rev==n)
{
printf("The number is a pallindrome");
}
else{
printf("The number is not a pallindrome");
}
return(0);
}
Comments
Post a Comment