C++ rand() Generates 10 pseudorandom numbers

Description

C++ rand() Generates 10 pseudorandom numbers

#include <iostream>
#include <cmath>
#include <ctime>
using namespace std;
int main()/*from   w  w  w. j  ava 2  s  .c o  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