469,300 Members | 2,205 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,300 developers. It's quick & easy.

3 dice rolling program

Anybody know how to write a 3 dice rolling program like this


Sample output

Welcome to the dice roller!

First of all, please enter a seed for the random number generator. This should be a positive integer: 3

How many times would you like me to roll the 3 dice?
Enter your choice here: -9
Sorry, please enter a positive number: 100

Okay, Ill roll the dice 100 times and find the sum each time.

Here are the results:

Sum Frequency
3 0
4 1
5 3
6 3
7 6
8 15
9 12
10 18
11 13
12 13
13 3
14 6
15 4
16 3
17 0
18 0
....

Please help!
Jan 17 '08 #1
2 3125
gpraghuram
1,275 Expert 1GB
Anybody know how to write a 3 dice rolling program like this


Sample output

Welcome to the dice roller!

First of all, please enter a seed for the random number generator. This should be a positive integer: 3

How many times would you like me to roll the 3 dice?
Enter your choice here: -9
Sorry, please enter a positive number: 100

Okay, Ill roll the dice 100 times and find the sum each time.

Here are the results:

Sum Frequency
3 0
4 1
5 3
6 3
7 6
8 15
9 12
10 18
11 13
12 13
13 3
14 6
15 4
16 3
17 0
18 0
....

Please help!

As the question say you should use the seed function and call the rand function to get the number.
In a single dice maximum number is 6 and so whatever number you get mod it(%) by 6 to get a single dice value and same process for other piece.
Now you have value for one dice.
Youe should be using same logic for 3 pair of dice.
Hope you are understanding this

Thanks
Raghuram
Jan 17 '08 #2
Studlyami
464 Expert 256MB
Take a look at this threat (that was on page 1 of the c++ forum).Here
Jan 17 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

1 post views Thread by lawentzel | last post: by
101 posts views Thread by Elijah Cardon | last post: by
4 posts views Thread by dpp4669 | last post: by
17 posts views Thread by Jose Durazo | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by harlem98 | last post: by
reply views Thread by harlem98 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.