+ 1
Why this code print same value when it is able print different value every time
4 Answers
+ 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.
+ 2
You forgotten to attach the code... ?
+ 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));
...
}
- 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