Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

/* 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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle Database Foundations Technology Fundamentals For IT Success

Authors: Bob Bryla

1st Edition

0782143725, 9780782143720

More Books

Students also viewed these Databases questions

Question

6. Briefly compare the old and new labor economics.

Answered: 1 week ago

Question

c. How is trust demonstrated?

Answered: 1 week ago