[/code]
/**************************************************
Filename: main.c
Author: Mike Hartwig
Purpouse: Generate given amount of prime numbers.
Input: Keyboard
Output: Screen
************************************************** */
#include <stdio.h> /* Pre-processor*/
#include <stdlib.h> /* */
#include <math.h> /*Directives */

int main ()
{
int prime_amount; //the amount of primes to generate.
int prime_answer = 3; // the answer.
int totcount;

printf("Welcome to the Prime Number Generator.\n");
printf("How many prime numbers would you like to generate: ");
scanf("%d", &prime_amount); //asking for Prime_amount

if (prime_amount < 0) //dont print any primes if given amount is less than 0
{
printf("Please Enter A Number Greater Than 0\n");
}

else
{
printf("Generating %d prime numbers...\n", prime_amount);
}

if (prime_amount > 4)
{
printf("2 3 5 7 ");
}

do
{
prime_answer++; //increment prime_answer

if (prime_answer %2 != 0 && prime_answer % 3 != 0 && prime_answer % 5 != 0 && prime_answer % 7 != 0)
{
printf("%d ", prime_answer);
}

if (prime_amount == 1)
{
printf("2");
}
if (prime_amount == 2)
{
printf("2 3 ");
}
if (prime_amount == 3)
{
printf("2 3 5 ");
}
if (prime_amount == 4)
{
printf("2 3 5 7 ");
}
}

while (prime_answer <= prime_amount); //stop printing primes when hit prime_amount

return (0); //all done
}
[code]

There is only one thing I need help with. It is supposed to print a given amount of primes, not until it gets to the given number. IE. Say the user puts in 100, right now it will stop at like 97 or something, but its supposed to print 100 of them. Im not to good at programming, and am just trying to get by in the class. Im about to give up. I dont know why I am having sutch a hard time.