Modulus

rand() % 10 --> 0 to 9

How about, rand() % 10 + 2? And what is the meaning of this line? Tks.
Try it.

0+2 to 9+2.

:-)
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
Topic archived. No new replies allowed.