I have to make a craps game and in the end, I have to make some probability. Here is my code so far. I want the loop to repeat 1000 times and look for the "probNumb" that the user entered. I'm not sure if it did the right thing, but let me say that I entered number 5. This is what I get. "Of 1,000 times, 5 were rolled 1,000 times."
Thus, it was not considered how many times were carried out 5 times. I am not allowed to use break or continue statements, only loops, and if others.
cout << "What number do you want the probability of ?"; cin >> probNumb; while (probCount < 1000) { ranNumb= 1 + (rand() % (5 + 1)); ranNumb2= 1 + (rand() % (5 + 1)); ranNumbFin = ranNumb + ranNumb2; probCount++; if (ranNumbFin = probNumb) probNumbCount++; } cout << "Out of 1000 times, " << probNumb << " was rolled " << probNumbCount << "times." << endl;
Naman source share