Printing unspecified set of numbers

Hi,

I was wondering, how are we able to print out a random number (after using srand() and rand() ) - where you there is an unspecified amount of variables given. So, if the user selects yes to have another number given, how are we able to show the previous numbers and the current one?

Thanks in advance.
closed account (j3Rz8vqX)
It all depends on your imagination; and capabilities - if you don't know it, learn it.

A solution would be to store every number retrieve from your random number generator into an array or container of some sort.

Assuming you want access to every value ever generated, you could simply use a vector and push_back() every value.

But that would force you to know how to design, implement, and operate vectors.

if the user selects yes to have another number given, how are we able to show the previous numbers and the current one
aka an iterator.
http://www.cplusplus.com/reference/iterator/

Find a suitable container of your choice and create an processing operation that would allow you to print values and iterate though your collection.
Topic archived. No new replies allowed.