#include<stdio.h>
int main()
{
int i,j,t,a,b,k,c,f;
printf(“ENTER THE NO OF TEST CASES\n”);
scanf("%d",&t);
if(t>10)
exit(0);
int arr[2t];
printf("\nENTER THE RANGE FOR %d CASES\n",t);
for(i=0;i<(2t);i++)
{
scanf("%d",&arr[i]);
}
i=0;
for(j=1;j<=t;j++)
{
a=arr[i];
b=arr[i+1];
for(c=a;c<=b;c++)
{
int k=2;
while(k<c)
{
f=c%k;
if(f==0)
{
break;
}
k++;
}
if(k==c&&f!=0||c==2)
printf("\n%d",c);
You are getting TLE as the constraints are very large.
You can see **Primality test, sieve of Eratosthenes, or Rabin Miller test.
Also obey the above comment by @rjohari23 to avoid wrong answer.