Click here to Skip to main content
15,887,596 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have been asked to write a program to simulate tossing two dices simultaneously. The program will find out the probability of having one dice produce an even number and the other dice produce an odd number. The software is visual studio C++. Please this is pretty urgent.

What I have tried:

I am really confused since the question did not specify how many sides the dice has
Posted
Updated 16-Apr-20 20:26pm

Quote:
I am really confused since the question did not specify how many sides the dice has

Start with 6 sides (the most common dices).
Once you have a solution, try with another number of sides (including odd number od sides).
 
Share this answer
 
You can use the usual well known rand()[^] function or the more advanced pseudo-random generator[^] of C++ to simulate (independly) the throw of the dices.
Then by means a very great number of throws, give an estimate of the requestd probability (additionally you may compare such an estimate with the theorical expected value).

[update]
Fixed my bad English, thanks to Richard.
[/update]
 
Share this answer
 
v2
Comments
Richard MacCutchan 17-Apr-20 4:01am    
"dices"
One is die, two or more is dice. Yes, I know crazy English language; taught us by you Romans. :)
CPallini 17-Apr-20 4:40am    
Similar to 'mouse', I guess. Thank you very much, Richard.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900