By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,847 Members | 2,354 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,847 IT Pros & Developers. It's quick & easy.

3 dice rolling program

P: 1
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, Iíll 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
Share this Question
Share on Google+
2 Replies


gpraghuram
Expert 100+
P: 1,275
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, Iíll 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

Expert 100+
P: 464
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.