I've been trying for last 3 days to overcome the problem but I'm failing continuously.
I'm trying to print all prime numbers from 1 to 300 in C.(Dev C++)
below is the code
#include <stdio.h>
#include <conio.h>
main() {
// 1 - 300
register int i, j;
for (i = 1; i <= 300; i++) {
for (j = 2; j < i; j++) {
if (i % j == 0) {
break;
} else {
printf("\n%d", i);
break;
}
}
}
}
please help me in this and also help me to clear the concept. Thanks.