Code://Program 2.5 - Using Random Integers
include<iostream> //Input/Output Stream
#include<cstdlib> //CstdLibrary
#include<ctime> //CTime
using std::cin; //Define cin
using std::cout; //Define cout
using std::endl; //Define endl;
using std::rand; //Define rand;
using std::srand; //Define srand;
using std::time; //Define time;
int main(){ //Initiate function main()
const int limit1 = 500; //Upper limit for one set of random values
const int limit2 = 31; //Upper limit for another set of values
cout << "First we will use the default sequnce from rand().\n"; //Output
cout << "Three random integers from 0 to " << RAND_MAX << ": " //Integer from 0 to 32767
<< rand() << " " << rand() << " " << rand() << endl; //Random integers
cout << endl << "Now we will use a new seed for rand().\n"; //Output
srand((unsigned int)time(0)); //Set a new seed
cout << "Three random integers from 0 to " << RAND_MAX << ": " //Integer from 0 to 32767
<< rand() << " " << rand() << " " << rand() << endl; //Random integers
cout << endl << "Please press the return (enter) key to exit the program . . ."; //Output
cin.get(); //Wait for keypress(enter)
return 0; //Return successful
}