+ 1
[C++] rand() is giving me the same number over and over
I need help, every time I run this code: randomNumber = 1+(rand()%3); cout << randomNumber; The output in the console every time I run the program is always 3, but it's supposed to be a random number between 1 and 3.
2 Respostas
+ 11
You did not seed it first with srand(time(0)); include <time.h> to use it.
+ 1
Thanks for the help.