PRIME VISITS-I dont understand why all test cases are not getting cleared

#include
using namespace std;
bool primecheck(long int n)
{ long int i;
if(n==1)
return 0;

for( i=2;i*i<=n;i++)
{
    if(n%i==0)
        return 0;
}

return 1;
}
int main() {
int t;
cin>>t;
while(t–)
{ long int a,b;
int count=0;
cin>>a>>b;
for(long int i=a;i<=b;i++)
{
int check= primecheck(i);
if(check)
{
count++;
}

    }
    cout<<count<<endl;


}
return 0;

}

Hello @Anchal,
You need to use optimised prime sieve approach to solve this question in order to avoid getting time limit exceeded.
Before taking any inputs, declare a boolean array and mark all the primes as 1 using sieve of eratosthenes.
Then for each testcase check for primes by checking if the number is marked 0 or 1 in the array.
For Prime sieve, refer to the tutorial videos on the online.codingblocks.com portal.
Do ask if any you encounter any problems.