If you don't know how to make loops, it means that you no nothing about programming. In turn, it makes you not qualified even for asking questions. Why? Because anyone can read in a manual how to program loops in C++. You did not even try. If you did not do that, it makes doubtful that you can learn how to do it from the answer. But who wants to waste time?
So, please sit down and learn the subject at least to the point where you can ask qualified questions.
http://www.cplusplus.com/doc/tutorial/control[
^],
http://www.cplusplus.com/forum/beginner/120231[
^].
And so on…
Sorry for not writing a code sample for you; I did it on purpose: to really help you to learn things. Answering such "questions" as yours is often works as an effective block for learning; I don't want it.
—SA