### help!!!!!!!!!!

this is what code i have an this is what i need...Write a program that simulates the tossing of 3 die and computes the probability of obtaining each of the values 3 to 18. Your program should ask the user how many rolls to simulate, and then perform the simulation and report the results. Include an appropriate srand() function so you get different results each time.
 ``123456789101112131415161718192021222324252627282930313233343536373839404142`` `````` #include "stdafx.h" #include using namespace std; #include #include #include int pairofdiceroll(); int main() //int _tmain(int argc, _TCHAR* argv[]) { int rollarray[18]={0}; int numrolls; int i; srand(static_cast(time(NULL))); cout << " How many roll?"; cin >> numrolls; for (i=0; i(rollarray[i])/numrolls)*100 << "%)\n"; } return 0; } int pairofdiceroll() { int result; int d1 = rand()%6+1; int d2 = rand()%6+1; int d3 = rand()%6+1; result = d1+d2+d3; return result; }``````
In order to hold numbers from 0 (the index an array starts at) to 18, an array should have 19 elements.

If you're recording the actual numbers rolled from 3 to 18, you don't need to make adjustments when you're displaying the results (and what gives you the idea that 18-3 is 11?)

In short, line 13 should be: `int rollarray[19] = {0};`
line 27 should be: `for (unsigned i=3; i<19; ++i )`
and on line 30 you should replace `i+3` with `i`.

Three die are not a pair.

"Here is my code. I'm not going to tell you what it actually does, but this is what is required" is not a good way to ask questions. "Help!!!!!!!!" is a very, very crappy subject, which is specifically warned against in the sticky at the top of this very forum (that you were apparently too lazy to read.)
Last edited on
Topic archived. No new replies allowed.