How to reduce time complexity

heyy on submission of this code , one test case is showing TLE so how can i optimise this code.

#include
using namespace std;

bool isprime(int num)
{
if(num==0 || num==1)
return false;

for(int i=2;i<num;i++)
{
    if(num%i==0)
    return false;
}

return true;

}

int primevisits(int a, int b)
{
int count=0;
for(int i=a;i<=b;i++)
{
count+=isprime(i);
}

return count;

}
int main() {

int t,a,b;
cin>>t;

while(t>0)
{
    cin>>a>>b;
    int ans=primevisits(a,b);
    cout<<ans<<endl;
    t--;
}
return 0;

}

You need to solve this problem using the prime seive optimisation technique given in online lecture of your course… under number theory section…