Hi, I'm going through the "Learn C on the Mac" book and getting a bit stuck. I've read through this part of the book countless times now. The exercises at the end of the chapter are modify teh program to computer the prime numbers from 1-100 and another one is to compute the first 100 prime numbers.

Code:

#include <stdio.h>
#include <stdbool.h> //This is to bring in the define of true
#include <math.h> //This is to bring in the define of sqrt()
int main (int argc, const char * argv[]) {
bool isPrime;
int startingPoint, candidate, last, i;
startingPoint = 235;
if ( startingPoint < 2 ) {
candidate = 2;
}
else if ( startingPoint == 2 ) {
candidate = 3;
}
else {
candidate = startingPoint;
if (candidate % 2 == 0) /* Test only odd numbers */
candidate--;
do {
isPrime = true; /* Assume glorious success */
candidate += 2; /* Bump to the next number to test */
last = sqrt( candidate ); /* We'll check to see if candidate */
/* has any factors, from 3 to last */
/* Loop through odd numbers only */
for ( i = 3; (i <= last) && isPrime; i += 2 ) {
if ( (candidate % i) == 0 )
isPrime = false;
}
} while ( ! isPrime );
}
printf( "The next prime after %d is %d. Happy?\n",
startingPoint, candidate );
return 0;
}

I understand what's going on in the code, just not sure how to implement those features. I don't really want someone to do it for me, just give me a few pointers.

Thanks.