Time Limit Exceed Error. Simple Array Question

https://online.codingblocks.com/player/34497/content/13211/4712

#include<bits/stdc++.h>
using namespace std;
bool isprime(int n){
if(n<=1)
return false;
for(int i = 2;i<=sqrt(n);i++){
if(n%i==0)
return false;
}
return true;
}
int main() {
int n,a,b;
cin>>n;
while(n–){
cin>>a>>b;
int count = 0;
for(int i = a; i<=b ; i++){
if(isprime(i)){
count++;
}
}
cout<<count<<endl;
}
}

the third test case in the given problem gives TLE.