C++ examples for Data Type:Random
Generates 10 pseudorandom numbers with C++'s rand() function
#include <iostream> #include <cmath> #include <ctime> using namespace std; int main()// w w w . jav a 2 s. c om { 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; }