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
11/27/2016 12:21:35 PM
Julia Melnik2 Answers
New AnswerTo 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
Learn Playing. Play Learning
SoloLearn Inc.
4 Embarcadero Center, Suite 1455Send us a message