+ 1

Please explain this!!!

i don't understand that what is the use of srand() function coz rand() doing the same thing so why we use this function please explain this?

13th Feb 2017, 5:55 AM
Ankur
Ankur - avatar
2 ответов
+ 1
srand() is used to seed the random. rand() is not truly random, but just runs a algorithmic pattern of possibilities and will eventually become predictable. Common practice is to seed rand() with the current time in milliseconds each time it is used to make the generator behave more like a true random function. srand (time(NULL)); printf ("Random number: %d\n", rand()%100);
13th Feb 2017, 6:02 AM
ChaoticDawg
ChaoticDawg - avatar
0
i cant understand how it works.
15th Feb 2017, 1:23 AM
Naethra.K