int main(void) { // your code here int t,m,n,i,j,c=0; // your code here scanf("%d",&t); while(t–) { scanf("%d %d",&m,&n); for(i=m;i<=n;i++) { for(j=1;j<=i;j++) { if(i%j==0) c++; } if(c<=2 && i!=1) printf("%d\n",i); c=0;
} printf("\n"); } return 0;
}
If you read it all --> http://discuss.spoj.com/search?q=prime%20generator --> you surely find answer for your question!
BTW -----> https://www.google.pl/search?dcr=0&q=prime+numbers+algorithm&sa=X&ved=0ahUKEwj4mf-MvonYAhWKZ1AKHf8YAYcQ1QIIgwEoAA
BTW 2 Your code is ugly pasted and heve to much: // your code here ________>