Hey there!
Look, I won't do your homework for you, but I can give you some pointers to help you do it. :)
Well, lets go on a logic sequence:
int HowManyPrimes();
Ok, this is a simple one, it is supposed to keep on asking the user for a positive integer until he actually inputs one. It will be just like the AskPosNumber() function.
void ShowPrimes(int primeNum)
Clearly this will be the main function of your program. It will do most of the work: getting prime numbers and priniting them out on the console on rows of 10. You will need two variables:
1 2
|
int numOfPrimes;
int currNum;
|
The while loop's body should be executed while numOfPrimes is smaller than the function argument primeNum.
I'd recommend you to also create a NUM_PER_ROW [or something like that] constant to keep track of how many numbers you want per row, in your case, 10. It makes your code cleaner and more flexible ;).
Ok, so, numOfPrimes should be incremented whenever a number is actually printed and currNum will serve as your test number to pass to the IsItPrime(int number).
Moving on, in order to format the ouput you need to have the assistance of your numOfPrimes. I assume you have already learnt about formating the output in terms of rows but anyway, when this numOfPrimes has reached 10, 20, 30, 40... it should print a new line('\n') character, right?. What do these numbers have in common? They are all multiples of 10, this means that when
numOfPrimes%NUM_PER_ROW == 0
you should print a '\n' character.
I hope I could be of help,
Good luck on your work and best regards,
~Deimos
PS: Post back if you still have any questions, but please don't ask us to write the actual program.