onecrazeemom wrote:
> I finally completed the dice roll program. Now, what do I do to make
> the rolls more random? They seem to come up with doubles quite often.
> I used srand( time(0)) to get my random numbers. I used the modulus(I
> think that is what it is called) 
>
> dieOne = 1 + rand() %6;
> dieTwo = 1 + rand() %6;
>
> srand( time(0) );
>
> Just curious what gives you a true random number when the lines of
> code are run so close together. Here are a couple of rolls:
>
> 1. 3, 1
> 2. 6, 1
> 3. 6, 2
> 4. 5, 5
> 5. 1, 1
> 6. 3, 4
> 7. 4, 6
>
> I guess they are more random than I thought, but the first two times I
> ran the program it came up with doubles.
>
> Thanks in advance,
> Stephanie
You should be using srand(time(0));  only ONCE in your program.
and if you do the math, you'll find that about 1/6 of the rolls will be 
"doubles"

Reply via email to