unsigned seed; cout << "Enter a seed for the random number generator: "; cin >> seed; srand (seed);
srand(unsigned (time ( (time_t *) NULL) ) );
x = rand(); // an integer between 0 and RAND_MAX x = rand() % 1000; // an integer between 0 and 999 x = 5 + rand() % 10; // an integer between 5 and 14 y = rand()/ (double) rand(); // a real number
The C++ Library has other classes for random number generation. You are welcome to use any of them.