Question: Write in C Write a program which simulates the rolling of two six-sides dice 100 times. The rolling of each die should be simulated using
Write in C
Write a program which simulates the rolling of two six-sides dice 100 times. The rolling of each die should be simulated using the rand() function which is in the stdlib.h library. Each roll should produce a number between 2 and 12. Have the program print a histogram of the number of times each value occurs.
The program should print one row for each value between 2 and 12. Each row should contain three things:
1.The rolled value (2-12)
2.The number of times, n, that the value was rolled
3.n asterisks to depict the histogram. For example, if there are 28 rolls of 7, the output line ``7:28'' should also contain a horizontal row of 28 asterisks.
The output might look like this:
2: 2 **
3: 5 *****
4: 4 ****
5: 10 **********
6: 15 ***************
7: 28 ****************************
8: 12 ************
9: 9 *********
10: 7 *******
11: 5 *****
12: 3 ***
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
