0

When we use rand() in random, why do we always get 41 as the filing output while it should vary with every outcome?

6th Jan 2018, 3:49 PM
Mohit M Gulecha
Mohit M Gulecha - avatar
7 Respuestas
6th Jan 2018, 3:57 PM
jay
jay - avatar
+ 7
use srand() or srand(time(0))
6th Jan 2018, 6:36 PM
I'm_Groot
I'm_Groot - avatar
6th Jan 2018, 6:45 PM
I'm_Groot
I'm_Groot - avatar
+ 6
Change the seed value to get other values.
6th Jan 2018, 3:52 PM
Sebastián Zapata
Sebastián Zapata - avatar
+ 4
Since most(almost all except some scientific) computers can't generate random number what they do is generating pseudo-random number. To do this what they do is take a seed value(initial value) and do some calculations on it so as to change. you can change seed value using srand() function in c/c++.
6th Jan 2018, 4:35 PM
shobhit
shobhit - avatar
+ 3
In what language are you writing? Idk what would to be. But any value that you pass to the seed will change the random number you get
6th Jan 2018, 3:56 PM
Sebastián Zapata
Sebastián Zapata - avatar
0
What's seed value
6th Jan 2018, 3:53 PM
Mohit M Gulecha
Mohit M Gulecha - avatar