dimanche 20 novembre 2016

C++, Random Numbers, Functions

been trying to solve the following C++ question but have made no progress:

Write a C++ program to simulate the tossing of 2 dice a large number of times. Use a function called rand_int() that returns a random integer between 1 and 6 using the rand() function. Inputs to the function are two integer values for the range required (in this case 1 and 6), output is the random integer over the span (in this case 1, 2, 3, 4, 5 or 6). You will need to set the seed using srand() so the random number generator does not always report the same series of values, this can be user input. A better way to set it to a new seed value continuously is to use the computer clock -this will involve additional investigating online! Using a loop, run the program at least 1000 times, and count each sum of the dice toss (roll). Count and find the percentage of rolls that are 2 to 12.

Any help would be appreciated very much!




Aucun commentaire:

Enregistrer un commentaire