Write a C program that includes the above statement (before main) and use the given function internally to calculate the average of n rolls of the die, where n is a positive integer entered by the user using scanf. To calculate the average, we have to add the value obtained from each roll of the die and divide this sum by n. Since n is an integer, the variable that accumulates the mean must be double so that the mean value has decimal places, as requested below. The mean value must be printed with printf to one decimal place.
The "dice" function implements a pseudo-random number generator that is used to simulate the throwing event of a die, the result of which can be the value of one of the 6 sides of the die, that is, an integer value from 1 to 6 .
image
Write a C program that includes the above statement (before main) and use the given function internally to calculate the average of n rolls of the die, where n is a positive integer entered by the user using scanf. To calculate the average, we have to add the value obtained from each roll of the die and divide this sum by n. Since n is an integer, the variable that accumulates the mean must be double so that the mean value has decimal places, as requested below. The mean value must be printed with printf to one decimal place.
Step by step
Solved in 2 steps with 1 images