+ 1

How to use random function in c++

5th Nov 2016, 6:34 PM
Nishant Chhattani
Nishant Chhattani - avatar
2 ответов
0
If you write int main() { cout << rand(); } then it will put out a random number.
5th Nov 2016, 6:49 PM
TheLastCookie
TheLastCookie - avatar
0
After include time.h library... int main(){ srand( time( NULL ) ); // True random numbers cout << "Example: \n" << rand() // Random << endl << rand() % 50 + 3; // Random ( 3 - 50 ) }
5th Nov 2016, 8:46 PM
M. de Vargas