/**************************************************************** Copyright (C) : University of Michigan Project: ENG101/200 - Class example File: rand1.cpp Purpose: An example of the rand() function Compiler: g++ Programmer: Alex Bielajew Start Date: 09/28/10 ****************************************************************/ /* Remarks: The user seeds the random number generator. */ //File: rand1.cpp #include #include #include // Need this for the rand(), srand() functions using namespace std; int main(void) { cout << "\n\nRAND_MAX = " << RAND_MAX << "\n\n"; // NEW STUFF ////////////////////////////////////////////////////// cout << "Input any int to seed the random number generator: "; // int seed; // cin >> seed; // srand(seed); //Only do this only once, before 1st call to rand() // //################################################# // // END OF NEW STUFF /////////////////////////////////////////////// cout << "The first 10 random numbers are...\n"; for(int i = 1; i <= 10; i = i + 1) cout << "Random number " << setw(2) << i << " = " << rand() // Random int between 0 and RAND_MAX incl.a << "\n"; return 0; }