Question: Program C, use LOOP only. No ARRAY . just like in following sample To Create one program to do 3 following: 1. Calculates the number
Program C, use LOOP only. No ARRAY. just like in following sample
To Create one program to do 3 following:
1. Calculates the number of times the sum of the randomly rolled dice equals each possible value from 2 to 12.
2. Repeatedly asks the user for the number of times to roll the dice, quitting only when the user-entered number is less than 1. Hint: Use a while loop that will execute as long as numRolls is greater than 1. Initialize numRolls correctly.
3. Make it to prints 2 seperated function for STATISTICS and HISTOGRAM in which the total number of times the dice rolls equals each possible value is displayed by printing a character like * that number of times, as shown below.
Dice roll histogram: 2: ****** 3: **** 4: *** 5: ******** 6: ******************* 7: ************* 8: ************* 9: ************** 10: *********** 11: ***** 12: ****
SAMPLE:
The following calculates the number of times the sum of two dice (randomly rolled) equals six or seven.
#include
int main(void){ int i; // Loop counter iterates numRolls times int numRolls; // User defined number of rolls int numSixes; // Tracks number of 6s found int numSevens; // Tracks number of 7s found int die1; // Dice values int die2; // Dice values int rollTotal; // Sum of dice values numSixes = 0; numSevens = 0;
printf("Enter number of rolls: "); scanf("%d", &numRolls);
srand(time(0)); if (numRolls >= 1) { // Roll dice numRoll times for (i = 0; i
Expected output showing as: "

keep enter input and output printout, it stops until 0 entered, then Dice Roll Statistics & Dice Roll Histogram as following:

Enter number of rolls Roll 1 is 3+4 Roll 2 is 5 (3+2) 11 3 is 3 2+1 Roll 4 is 9 6+3 11 5 is 6
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
