Question: Roll two dice one red and one blue 1 0 0 0 times each. As you roll the dice you will need to keep track

Roll two dice one red and one blue 1000 times each. As you roll the dice you will need to keep track of how many times each number appears for both dice (storing the information in an array fro each die). After you have rolled the blue die and the red die 1000 times each you will need to display to the screen the frequency of each number on the blue die and then the red die. Your output should look similar to this:
The result of rolling 2 dice 1000 times each is:
Blue Dice
Red Dice
1 rolled 196 times 1 rolled 195 times
2 rolled 197 times 2 rolled 197 times
3 rolled 196 times 3 rolled 199 times
4 rolled 198 times 4 rolled 194 times
5 rolled 196 times 5 rolled 198 times
6 rolled 197 times 6 rolled 196 times
For this assignment you will need to include the cstdlib header file. This will allow you to access the predefined functions rand() & srand(). These two functions will allow you to randomly generate numbers.
You should have the following 3 functuions:
void rollDie(int die[SIZE]); //rolls a die 1000 times and fills array
void display(const int red[SIZE], const int blue[SIZE]); //displays the contents of the
/larrays in a table as shown above
void initialize(inty die[SIZE])/initializes the array to zeros
I would also assume that in maing you would have 21D-arrays defined such as redDie[SIZE] and blueDie[SIZE]. Where SIZE is a global conatant of 6 representing the siz sides of a standard die.
Roll two dice one red and one blue 1 0 0 0 times

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!