+ 3

C++

what is the rule of srand in rand numbers ?

22nd May 2018, 12:17 PM
Jamaluddin Huseinkhail
Jamaluddin Huseinkhail - avatar
2 Antworten
+ 2
srand sets a new seed for the pseudo random number generator. A seed means is like a start value. If you don't change the seed, rand might return always the same values
22nd May 2018, 1:32 PM
Aaron Eberhardt
Aaron Eberhardt - avatar
+ 1
srand() uses its argument seed as a seed for a new sequence of pseudo-random numbers to be returned by subsequent calls to rand(). If srand() is not called, the rand() seed is set as if srand(1) was called at program start. Any other value for seed sets the generator to a different starting point. The rand() function generates pseudo-random numbers.
22nd May 2018, 5:03 PM
Mohit Ranjan