Is it possible to do a srand and then put a rand inside of it? Like this? srand (rand() ); ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Is it possible to do a srand and then put a rand inside of it? Like this? srand (rand() ); ?

5th Jun 2018, 2:43 PM
Fizzleburn
2 Answers
+ 2
Try it and see. But the problem is that we are trying to produce random numbers which we get from time which is continuously changing. That means we need to seed the rand() function that we put into srand() too to get random numbers. Otherwise you will get the same numbers.
5th Jun 2018, 2:46 PM
Yusuf
Yusuf - avatar
+ 1
ok... thanks!
5th Jun 2018, 2:48 PM
Fizzleburn