+ 3

What does srand(98) and srand(time (null)) mean?

12th May 2017, 1:05 PM
iheb
4 odpowiedzi
+ 7
seeds rand the first srand(98) will result in repeatable numbers from rand each time the program is run. the second supplies the system clock time as a seed value. as a result the numbers generated by rand will be different each time the program is run.
12th May 2017, 1:54 PM
jay
jay - avatar
+ 6
you are welcome. note: the seed is the value in the braces srand(seedValue) if we supply the number 1 as a seed we will get a certain set of results everytime we use rand but they will be different than if we had supplied 98.
12th May 2017, 2:06 PM
jay
jay - avatar
+ 1
thank you
12th May 2017, 1:57 PM
iheb
+ 1
Ok, but what if we gave it some other number ?
17th Jun 2019, 4:04 PM
Archit Sood