Randomizing the Random Number Generator

Executing the program of Fig. 6.7 again produces

         6         6         5         5         6         5         1         1         5         3         6         6         2         4         2         6         2         3         4         1

The program prints exactly the same sequence of values shown in Fig. 6.7. How can these be random numbers? When debugging a simulation program, this repeatability is essential for proving that corrections to the program work properly.

Image

Function rand actually generates pseudorandom numbers. Repeatedly calling rand produces a sequence ...

Get C++11 for Programmers, Second Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.