I am a newbiee here and this is my first post. I hope that I’m posting it in correct section.

So, I was trying to solve a problem Prime Generator in which we’ve to find all the prime numbers between 2 specified numbers.

https://www.codechef.com/problems/PRIME1

Here’s my solution: https://www.codechef.com/viewsolution/25858968.

Is this a better method to find a prime number?

#include <stdio.h>

int main(void) {

int t, start, end, i;

scanf("%d", &t);

while(t–) {

start = 0;

end = 0;

scanf("%d %d", &start, &end);

for(i=start; i<=end; i++) {

if(i!=1) {

if(i==2 || i==3 || i==5 || i==7)

printf("%d\n", i);

else if(!(i%2==0) && !(i%3==0) && !(i%5==0) && !(i%7==0))

printf("%d\n", i);

}

}

printf("\n");

}

return 0;

}