SPOJ- PRIME GENERATOR WHY THIS CODE IS SHOWING TLE error

#include<stdio.h>

int main()
{
int t,a,b,i,j,k,ct;
scanf("%d",&t);
for(i=1;i<=t;i++)
{ scanf("%d%d",&a,&b);

  for(j=a;j<=b;j++)
   { for(k=2,ct=0;k<=j/2;k++)
    {if(j%k==0)
       ct++;}


      if(ct==0)
       printf("%d",j);

}

printf("\n");
}
return 0;
}

Can you share the question link please

Please share the question link. From the code it looks like you are trying to find all the primes between a and b. If so, your approach will time out. Just give a large a and b and run your code on your system. You can see how long it takes.

Then study segmented sieve and implement that. If you don’t know sieve, start with sieve-of-eratosthenes and do a couple of problems from that. Then move to segmented sieve.