0

Please Explain rand and srand in C++ and their Functions. If possible share your code on how you used it. Thanks

C++

30th Sep 2019, 8:57 PM
James Harrison
James Harrison - avatar
3 Réponses
30th Sep 2019, 9:51 PM
rodwynnejones
rodwynnejones - avatar
0
Thank you very much
30th Sep 2019, 10:00 PM
James Harrison
James Harrison - avatar
0
As most of us know that when we generate a random number by using "rand()" it'll always give us the same numbers over and over. By using "srand()" we get a random number but we should change the values inside the brackets of the srand. So our final solution to generate a random number without the need of changing the values inside the srand's brackets each time we use "time(0 or null)" inside the srand's brackets. This will generate random numbers every time we run our program.
29th Nov 2019, 7:58 PM
The unknown 321
The unknown 321 - avatar