CPP
95
random
Guest on 20th April 2022 02:13:21 AM
#include <iostream>
// The c standard library, math and time libraries are needed.
#include <cstdlib>
#include <cmath>
#include <ctime>
using namespace std;
// Pick a random number from 1 to 10.
int main() {
// Random number picked.
int random_number=0;
// Maximum random number to pick.
int max_random=10;
// Set the randomization seed to be based on the current time in seconds in Jan 1, 1970.
srand((unsigned)time(0));
// Pick a random number from 1 to max_random.
random_number=rand()%max_random+1;
cout << "Random number picked: " << random_number << endl;
return 0;
}