What I'm usually doing with { and } is placing them on the same colum. So
Code:
while (condition)
{
/* some code */
}
In this way, it is much easier to find {}-pairs. A lot of programmers write:
Code:
while (condition)
/* a statement */
When more code is needed, you can easily forget the brackets. So it is a good style to do this:
Code:
while (condition)
{
/* a statement */
}
Further some comments on your code:
Code:
#include <stdio.h>
#include <stdlib.h>
int main ()
{
int prime_amount; //the amount of primes to generate.
int prime_start = 2; //the number to start generating primes at.
int prime_count; // the count of numbers we already have.
int prime_answer; // the answer.
printf("Welcome to the Prime Number Generator.\n");
printf("How many prime numbers would you like to generate: ");
scanf("%d", &prime_amount);
printf("Generating %d prime numbers...\n", prime_amount);
/* Shiro: you need to initialise prime_count before using it */
prime_count = INITIAL_VALUE;
do
{
/* Shiro: you forgot a ; at the end */
prime_answer = prime_start + prime_count * 2;
}
while (prime_count < 2);
printf("%d, \n", &prime_answer);
/* Shiro: usually 0 is used as "everything went OK" value */
return 0;
}