First n prime numbers

I've got to display the first n natural prime numbers,n being introduced from the keyboard.
Example:n=5
There will be displayed 2 3 5 7 11
I've got no idea how should I begin writing the code,so I would appreciate if someone would help me with it.Or,at least explain me what I should do,and WHY.Please,do not use functions.
You already had:
http://www.cplusplus.com/forum/beginner/210934/

If that works, then you know how to show every prime in a range [a,b].

This time you have a=2 (or can you think of a better start for the range?) and don't care about the b.

If you don't care about the b, how do you end the loop?
When you have seen n prime values.


A while-loop might look more intuitive for this than a for loop.
Last edited on
Topic archived. No new replies allowed.