cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
Beginners
Modulus
Modulus
Nov 11, 2009 at 11:50pm UTC
makan007
(77)
rand() % 10 --> 0 to 9
How about, rand() % 10 + 2? And what is the meaning of this line? Tks.
Nov 12, 2009 at 12:36am UTC
Duthomhas
(13206)
Try it.
0+2 to 9+2.
:-)
Nov 12, 2009 at 12:37am UTC
mcleano
(922)
That would be 2 to 11.
The highest possible value of rand() % 10 is 9, plus 2 is 11. The lowest possible value of rand() % 10 is 0, plus 2 is 2.
http://www.cplusplus.com/reference/clibrary/cstdlib/rand/
EDIT: Too slow :(
Last edited on
Nov 12, 2009 at 12:38am UTC
Topic archived. No new replies allowed.