0
I obsever that rand function 1st time always return 41 value.and in defination it say that rand function return random value.
i am so confused please clear this confusion.
2 Respostas
+ 2
Random function are in fact pseudo-random, because true randomness is hard to do. That means they will generate a number given some elements (a seed). That's why most languages ask you to give a seed to the random function, mostly using time (because it always fluctuates). Without giving a seed, you use the default seed, which (apparently) is similar each time you run the random function.
0
A common way to choose a different seed for the random generator is using the current time. Without some seed selection mechanism, the sequence of pseudo-random numbers generated is always the same, as you have already been told.