Search:
Forum
General C++ Programming
random number generation
random number generation
Jun 15, 2016 at 9:50am UTC
Vabi
(20)
Hi
I have developed a new program array of 10 number and I want to choose any one out of them randomly. How can I do that?
Jun 15, 2016 at 10:06am UTC
shadder
(813)
could you show us your program?
Jun 15, 2016 at 12:06pm UTC
Duthomhas
(13212)
First, you need a PRNG.
http://www.cplusplus.com/faq/beginners/random-numbers/
Next, you have two options.
1 - choose a random index into the array (using random_int_in_range() or something similar).
2 - randomize the array and choose the first item.
Hope this helps.
Topic archived. No new replies allowed.
C++
Information
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs