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
How to set random number generator to a
How to set random number generator to a range?
Mar 4, 2015 at 10:14pm UTC
samuel89m
(5)
Is there any way I can use random number generator with negative numbers? thanks
Last edited on
Mar 5, 2015 at 6:15pm UTC
Mar 4, 2015 at 10:17pm UTC
LB
(13399)
Generate between 0 and 2000 and then subtract 1000?
By the way,
rand()
and friends are deprecated - don't use them anymore. Instead, learn how to use the new C++11
<random>
header:
http://www.cplusplus.com/reference/random/
http://en.cppreference.com/w/cpp/header/random
Check out this example:
http://en.cppreference.com/w/cpp/numeric/random/uniform_int_distribution#Example
Topic archived. No new replies allowed.