Randomness is added to programs by using random numbers. These are generated by random number functions.
There are two primary random number functions available in the standard C / C++ system libraries:
Returns a random integer between 0 and 2,147,483,647.
The % operator is normally used to reduce this to a desired range.
e.g., random() % 100 returns a random number from 0 to 99.
Returns a random floating point number between 0.0 and 1.0 (including 0.0, but not 1.0).
The return value can be multiplied, added to, etc, to convert it to
some other desired range.
e.g. drand48() * 2.0 - 1.0 returns a random number from -1.0
to 1.0.
Example 1: forest.cpp
Example 2: launcher.cpp