**A random number generator**

At the beginning of the program, and whenever the ball hits a wall:

- A random number generator function named
**rand**is called to determine the direction in which the ball will travel.

A description of the rand function is shown in Figure 2.

**Figure 2. Description of the rand function. **

Returns a pseudo-random integral number in the range
0 to RAND_MAX. This number is generated by an algorithm that returns a sequence of apparently non-related numbers each time it is called. This algorithm uses a seed to generate the series, which should be initialized to some distinctive value using srand. RAND_MAX is a constant defined in A typical way to generate pseudo-random numbers in a
determined range using
Notice though that this modulo operation does not generate a truly uniformly distributed random number in the span (since in most cases lower numbers are slightly more likely), but it is generally a good approximation for short spans. |