previous
|
start
|
next
Simulations
The C++ library has a
random number generator
, which produces numbers that appear to be random.
Calling
rand()
yields a random number between 0 and
RAND_MAX
(usually 32767, but implementation dependent).
These numbers actual come from a a very long sequence of numbers computed from fairly simple formulas; they just behave like random numbers.
For that reason they are often called
pseudorandom
numbers.
The following program produces the
exact same output
every time the program is run (because the numbers are generated with formulas).
int main() { int i; for (i = 1; i <= 10; i++) { int r = rand(); cout << r << "\n"; } return 0; }
previous
|
start
|
next