/* This file is primemain.c. Print the prime numbers between 1 and 100, eight per line. */ #include #include int isprime(int n); main() { int n; int i = 0; /* count how many numbers printed so far */ printf ("The prime numbers from 1 to 100 are:\n"); for (n = 2; n < 100; ++n) { if (isprime(n)) { printf ("%5d", n); if (++i % 8 == 0) { printf ("\n"); } } } /* If the last number was not followed by a newline, add one now. */ if (i % 8 != 0) { printf ("\n"); } exit (0); }