+ 1
Rand Function
I run the rand() code snippet and the code spits out 41 each time. It seems less than random. A slight variation to the code, recompile and rerun it...same old 41. What's the deal??
4 Respostas
+ 9
Andrea Simone Costa is correct.
Martin Smith This is covered on the last slide of the rand() function in the c++ lessons.
https://www.sololearn.com/learn/CPlusPlus/1638/?ref=app
+ 3
Here is a code
https://code.sololearn.com/cvTV0y9F8Di8/?ref=app
+ 2
rand() needs a seed.
so #include <ctime> and do srand(time(NULL)); only once before using rand();
0
hi,
share the code, please