#include<stdio.h>
int pal(int n, int cal, int k);
int main( )
{
int n, k, cal=0, p;
printf("Enter the number: ");
scanf("%d",&n);
k=n;
p=pal(n,cal,k);
if(p==1)
printf("\n%d is palindrome\n",k);
else
printf("\n%d is not palindrome\n",k);
return 0;
}
int pal(int n, int cal, int k)
{
int i, t=0;
if(k==cal)
{
t=1;
return t;
}
if(n>0)
{
i=n%10;
n=n/10;
cal=cal*10+i;
pal(n,cal,k);
}
}
1 Comments
Can u please explain me,how it works? Anyone
ReplyDelete