Caleb likes to challenge Selvan's math ability. He will provide a starting and ending value that describes a range of integers, inclusive of the endpoints. Selvan must determine the number of square integers within that range.
#include<stdio.h>
#include<math.h>
void Clac_square(long int start,long int end)
{ int i,count=0;
for(i=start;i<=end;i++)
{ int n=sqrt(i);
if(n==sqrt(i))
count++;}
printf("%d\n",count);
}
int main()
{
long int q,start,end;
scanf("%ld",&q);
while(q--){
scanf("%ld %ld",&start,&end);
Clac_square(start,end);}
return 0;
}
Comments
Post a Comment