C++ srand() Generates 10 pseudorandom numbers

Description

C++ srand() Generates 10 pseudorandom numbers

#include <iostream>
#include <cmath>
#include <ctime>
using namespace std;
int main()/* w  w  w.  j  av  a2s.  co  m*/
{
   const int NUMBERS = 10;
   double randvalue;
   int i;
   srand(time(NULL));  // generates the first seed value
   for (i = 1; i <= NUMBERS; i++)
   {
      randvalue = rand();
      cout << randvalue << endl;
   }
   return 0;
}



PreviousNext

Related