0
I cant understand why srand() is used
2 Réponses
+ 6
srand() is used to 'randomise' the built-in RNG algorithm by providing a seed.
https://code.sololearn.com/cMUCJqFL1X65/?ref=app
+ 3
srand() gives you a random number from a seed value. To get a unique random number each time you run the program, you can pass the tinge as seed value because it keeps changing. Thus you can do srand(time(0)). It is very useful in different situations eg, doing a toss in a game or shuffling something.