Always the same random number - 2.
I always get the same number - 2... How to use random function correctly, to get a random number, not always the same?
1 2 3 4 5 6 7 8 9 10 11 12 13 14
|
#include <iostream>
#include <cstdlib>
using namespace std;
int main()
{
int rand_1to10 = rand() % 10 + 1;
cout << rand_1to10;
return 0;
}
|
Outputs 2 every time.
Topic archived. No new replies allowed.