How do I do this? I tend to use the simple method (for positive integers), which I've heard is a very poor choice, but I don't know how to combine it with negative values.
Code:rand() % 10 + 1
How do I do this? I tend to use the simple method (for positive integers), which I've heard is a very poor choice, but I don't know how to combine it with negative values.
Code:rand() % 10 + 1
Code:rand()%21 - 10
Hawkin pretty much gave you the answer that you were looking for, but also read Prelude's article on using rand().
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
Thanks for the help!