0
how to generate random number?
for example from 1 to 10
1 Answer
+ 1
Use the rand() function. It's mentioned in the tutorial, if you haven't gotten there yet.
srand(time(0)); // makes rand() actually random
cout << rand() % 10 + 1; // generates random # from 1 to 10