Question: /* moreRand.c This program generates 100 (pseudo)random integers and stores them in an array. */ /* includes rand() */ #include stdafx.h #include int main (void)

/* moreRand.c This program generates 100 (pseudo)random integers and stores them in an array. */ /* includes rand() */ #include "stdafx.h" #include int main (void) { int R[100], i; /* generate 100 random integers, and store in array */ for (i=0; i<100; i++) R[i] = rand(); /* print the results */ for (i=0; i<100; i++) { if (i%5 == 0) printf(" "); printf("%10d ",R[i]); } printf(" "); return 0; }

Your task now is to modify the program to repeatedly call roll and then keep track of how many times each number (1 through 6) occurs. Make the following changes to main: Remove the array R. Instead, introduce an integer variable r, which youll use to grab the most recently generated number (i.e., the value returned by roll()). Set up an integer array count[7], and use a loop to initialize all of its elements to 0. This array will be used to keep track of how many times a particular number is rolled. For example, count[5] will indicate how many times the result of a roll was 5.

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 Databases Questions!