Header Ads Widget

Palindromic Number

Problem:-(Print total number of palindromic numbers between two given number)

#include<stdio.h>
int palindrome(int n) // funtion definition
{
int n1,rev=0,r;
n1=n;
while(n>0)
{
r=n%10;
n=n/10;
rev=rev*10+r;
}
if(rev==n1)
return 1;
else
return 0;
}
void main()
{
int t,a,b,s,total=0;
scanf("%d",&t);
for(int i=0;i<t;i++)
{
scanf("%d%d",&a,&b);
for(int j=a;j<=b;j++)
{
s=palindrome(j); // function calling
total=total+s;
}
printf("%d\n",total);
total=0;
}
}