```
#include <stdio.h>
#include <stdlib.h>
#define NUM_PRIMES 1000
int main()
{
unsigned a[NUM_PRIMES+1];
unsigned p=3;
unsigned n=2;
unsigned i, c;
a[1]=2;
/* Seed the array of NUM_PRIMES prime numbers (2 is already done), outputting as we go */
do {
for (i=1; (a[i]*a[i])<=p; i++) {
if (p % a[i] == 0) break;
}
if (a[i]*a[i]>p) {
a[n]=p;
n++;
}
p+=2;
} while (n <= NUM_PRIMES);
/* Optimised code to test for primes once the array is seeded, good up to the square of the largest seed */
do {
for (i=2; (a[i]*a[i])<=p; i++) {
if (p % a[i] == 0) break;
}
if (a[i]*a[i]>p) {
c=p;
n++;
}
p+=2;
} while (p < a[NUM_PRIMES]*a[NUM_PRIMES]);
n--;
printf("%d\n", n);
printf("%d\n", c);
}
```