Question: c++ This program was written to generate ten random real-numbers of values ranging from 0 to 1 , as shown in the sample output below.
c++
This program was written to generate ten random real-numbers of values ranging from 0 to 1, as shown in the sample output below.
But, it doesn't work, please fix it and paste the correct program in the answer box:
#include
using namespace std;
int main() { int rand_num;
srand(unsigned(time(0)));
for (int idx = 1; idx < 10; idx++) { rand_num= 1 * rand() / RAND_MAX; // RAND_MAX is provided by the c-library cout << rand_num << endl; }
return 0; }
sample output:
0.650868 0.055269 0.111759 0.728446 0.234382 0.00561541 0.253792 0.0358592 0.972564 0.225501
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
