+ 2
srand() and If-statements
How do I generate a number when I have multiple If-statements? Where should I place the srand() function, before or after conditions? And what else do I need to add to the code
3 Answers
+ 4
To generated random number you need to use rand() function and srand() function use to initialization of rand. Put your srand above if statement. And initialize rand by srand(time(NULL)).
You have to use ctime header file for time function. it would work perfect.
if you want it within a range use
rand()%(max-min+1)+min
0
Helo
0
yes