### srand() function help

I need help putting together a program that simulates the tossing of 3 die and computes the probability of obtaining each of the values 3 to 18. It should ask the user how many rolls to simulate, and then perform the simulation and report the results. Including an appropriate srand() function so it doesn't compute different results each time.

What have you written so far?
I have no idea. This isn't like a homework assignment. I am just trying to find out how I would write such a program. Thanks
Seems like homework to me. Have you even started C++?
Yes, I started it in college but never really learned anything.
closed account (3qX21hU5)
Here is a function to help you get started it isn't totally complete so make sure you fill in the blank. But that should take care of the roll function that will be called whenever you want to roll the dice.
 ``123456789101112`` ``````int rollDice(int &one, int &two, int &three) { // Init srand with time for better random numbers one = rand() // Add something here so it gets the values 1 through whatever you want two = rand() // Add something here so it gets the values 1 through whatever you want three = rand() // Add something here so it gets the values 1 through whatever you want int total = one + two + three; return total; }``````
How does this look

 ``123456789101112131415161718192021`` ``````#include #include using namespace std; int main() { srand(time(0)); int num1 = rand() % 6 + 1; int num2 = rand() % 6 + 1; int num3 = rand() % 6 + 1; int sum = num1 + num2 + num3; cout<<"The first roll was: "<
Topic archived. No new replies allowed.