cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
General C++ Programming
rand help!!
rand help!!
Feb 28, 2012 at 12:15am UTC
jmrag
(19)
I'm trying to find an algorithm in order to pick a number from a range (5,x-5) while inputing the x.. But i really don't understand how rand works can you help me?
Feb 28, 2012 at 1:03am UTC
Aikon
(75)
Basically:
rand() % 10 + 1
With this you are getting a number from 1 to 10.
So:
rand() % range + start
PD: try to google it, I don't think you really need to post here!
Topic archived. No new replies allowed.