Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

ASSIGNMENT_4 Note: Read Chapter’s 6 and 7 with examples and complete the assignm

ID: 3681747 • Letter: A

Question

ASSIGNMENT_4

Note: Read Chapter’s 6 and 7 with examples and complete the assignment.

1.(Dice Rolling) Write a program that simulates the rolling of two dice. The program should use rand twice to roll the first die and second die, respectively. The sum of the two values should then be calculated. [Note: Because each die can show an integer value from 1 to 6, then the sum of the two values will vary from 2 to 12, with 7 being the most frequent sum and 2 and 12 the least frequent sums.] Your program should roll the two dice 36,000 times. Use a one-dimensional array to tally the numbers of times each possible sum appears. Print the results in a tabular format.

Below is a sample output:

              Below is a sample output:

Maximum Points: 20

Due Date: 11:59 PM, March 29th, 2016

Submission: Submit your source code to Blackboard.

need the source code in the c files.

Explanation / Answer

#include #include #include int main(void) { int number1,number2,sum,total=0,i; int frequency[13]={0}; int expected[ 13 ] = { 0, 0, 1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1}; srand(time(NULL)); for (i = 0; i < 36000; i++) { sum=0; number1=1+rand()%6; number2=1+rand()%6; sum=number1+number2; frequency[sum]++; } for (i = 0; i < 13; i++) { total+=frequency[i]; } printf("Sum Total Expected Actual "); for (i = 2; i < 13; i++) { printf("%2d %8d %f %9f ",i,frequency[i], 100.0*expected[i]/36,100*(double)frequency[i]/total ); } getch(); return 0; } POSSIBLE OUTPUT: Sum Total Expected Actual 2 1018 2.778% 2.828% 3 2008 5.556% 5.578% 4 3020 8.333% 8.389% 5 4024 11.111% 11.178% 6 4891 13.889% 13.586% 7 6011 16.667% 16.697% 8 5065 13.889% 14.069% 9 3984 11.111% 11.067% 10 2970 8.333% 8.250% 11 1989 5.556% 5.525% 12 1020 2.778% 2.833% */