Set a random initial direction of motion
After seeding the random number generator in
- The program calls the rand function
- Using the modulus operator approach described in
- To generate a random number between 0 and 3 inclusive.
This value is assigned to the variable named dir
- To cause the initial direction of motion of the ball in
Figure 1 to be random.