Need Some Coaching, Display 100 Prime Numbers
I've been working at this for awile and I need some help. I can print the first 100 non-prime numbers but not the first 100. What am I missing? This nested loop business is killing me. Here is what I have:
Code:
#include<stdio.h>
int main (void)
{
int num, test;
int prime = 0;
int not_prime = 0;
for (num = 2; num < 100; num++)
{
for (test = 2; test < (num - 1); test++)
{
if (num % test == 0)
{
printf ("%d\n", num);
break;
}
}
//printf ("%d\n", num);
}
}