C

Copy Code

include <stdio.h> int main() { int r = 80; printf("Prime Numbers Between 80 & 486 Are:\n"); while (r <= 486) { int i = 2; // this should be initialised at every iteration on r int n = 1; while (i < r) { if (r % i == 0) { n = 0; break; // the first 'zero-reminder' divison makes the primality test fail } ++i; } if (n == 1) printf("%d ", r); r++; } return 0; }

Alternatively, you could write:

C

Copy Code

#include <stdio.h> int main() { const int First = 80, Last = 486; printf("Prime Numbers Between %d & %d Are:\n", First, Last); for ( int number = First; number <= Last; ++number) { int divisor; for (divisor = 2; divisor < number; ++divisor) { int reminder = (number % divisor); if ( reminder == 0) break; } if ( divisor == number) { printf("%d ", number); } } return 0; }