+ 1

Why this code print same value when it is able print different value every time

22nd Oct 2018, 2:49 PM
shaaz
shaaz - avatar
4 ответов
+ 4
That's not what pseudo-random means. Even if you use srand() and the program generates different numbers each time, they are still pseudo-random numbers.
22nd Oct 2018, 3:05 PM
Anna
Anna - avatar
+ 2
You forgotten to attach the code... ?
22nd Oct 2018, 2:52 PM
Hatsy Rei
Hatsy Rei - avatar
+ 1
I'm not sure what code or programming language you're talking about, but you probably didn't use srand() and you're using the same seed and generating the same 'random' numbers each time you run the program. #include <time.h> int main() { srand((unsigned)time(NULL)); ... }
22nd Oct 2018, 2:52 PM
Anna
Anna - avatar
- 1
However, the rand() function will only return a pseudo random number. This means that each time the code is run, it generates the same numbers. I got my answer
22nd Oct 2018, 3:01 PM
shaaz
shaaz - avatar