I'm trying to use "rand" and "srand" to generate random numbers between 1 and 2 and then assigning heads to 1 and tails to 2 to simulate a coin flip. The explanation is probably just a bit of math I think. I need a better explanation of the following line:
return rand() % (high - low + 1) + low;
I'm not sure how "rand()" works or the use of %. I've attached the program as a text file.
Thanks,
Mike
return rand() % (high - low + 1) + low;
I'm not sure how "rand()" works or the use of %. I've attached the program as a text file.
Thanks,
Mike
Attachments
-
549 bytes Views: 4