Even a dude like me can follow this program.

Code:

startingPoint = 1;
if ( startingPoint < 2){
candidate = 2;
}

startingPoint is assigned 1.

1 is less than 2.

candidate is assigned 2.

And that's all that happens in your program. Let's fix it.
Code:

#include <stdio.h>
#include <stdlib.h>
#include <math.h> //used for extra math functions
#include <stdbool.h> // Used for the definition of truth WOW!
int main(int argc, const char * argv[]) {
int
j,k, /* secret */
i, /* index into primes */
isPrime,
maximum,
candidate,
primes_found = 0, /* mark the range of valid entries in primes*/
primes[50]; /* there are potentially 50 primes, the odd numbers greater than 1, and 2. */
primes[primes_found++] = 2; /* 2 is a prime number, odd because it's even. */
for (candidate = 3; candidate < 101; candidate += 2) { /* for loop iterating over odd numbers */
fprintf(stderr, "\ttesting %d", candidate); /* show diagnostic information on stderr */
maximum = 2 + (int)sqrt(candidate); /* need to test divisors only through sqrt(candidate) */
isPrime = true;
for (i = 1; (i < primes_found) && (primes[i] < maximum); ++i)
/*
start i at 1 because we already handled even numbers.
(i < primes_found) because these are the only valid entries in primes array
(primes[i] < maximum) because, you already understand why. Considering magnitude,
the product of two factors greater than the square root of a number exceeds the number.
*/
if ((candidate % primes[i]) == 0) {
isPrime = false;
fprintf(stderr, "\t%d is a factor.", primes[i]); /* more of these exciting diagnostics */
break; /* stop testing. We know the answer */
}
if (isPrime)
primes[primes_found++] = candidate;
fputc('\n', stderr); /* keep the diagnostics pretty */
}
/* do something with these primes. Show 'em */
printf("Found %d primes less than 101. They are:\n\n", primes_found);
k = primes_found / 5 + (! ! (primes_found % 5));
for (j = 0; j < k; ++j) {
for (i = j; i < primes_found; i += k)
printf("%4d",primes[i]);
putchar('\n');
}
return EXIT_SUCCESS;
}

Tweet This+ 1 thisPost To Linkedin