Header Ads

Learn Together, Stay Connected.

প্যালিন্ড্রোম গণনা-C


#include<stdio.h>
#include<math.h>

int palindrome(int n)
{
int num=0,temp,rem;
temp=n;
while(temp!=0)
{
rem=temp%10;
num=num*10+rem;
temp=temp/10;

}
if(n==num)
{
return 1;
}
}


int main()
{
int i,a,b,n1,n2,count=0;
scanf("%d %d",&a,&b);
if(a<b)
{
n1=a;
n2=b;
}
else
{
n1=b;
n2=a;
}

for(i=n1;i<=n2;i++)
{
if(palindrome(i)==1)
{
count++;
}
}
printf("%d\n",count);

return 0;
}

No comments

Theme images by Dizzo. Powered by Blogger.