void prompt_user(int& iterations)
{
cout << "\nThis program simulates thruster use for docking with ISS." << endl;
cout << "\nEnter the number of iterations to run: ";
cin >> iterations;
}
int generate_data(int iterations)
{
srand((unsigned)time(0));
int thrusters[iterations];
int i;
for (i = 0; i < thrusters[iterations]; i++)
{
int num = rand() % 40; // getting random number between 0-40
thrusters[iterations] = num;
}
return iterations;
}
1. main() method is missing
2. You're returning 'iterations' in generate_data(), which is the same as the parameter passed in.
3. loop section has issues w/ the condition and not making use of 'i' in the assignment. You're also not making use of 'num', so can get rid of that
1 2
for (int i=0; i<iterations; ++i)
thrusters[i] = rand() % 41;
3a. rand() % 41 is from 0 to 40, inclusive. What you had would be from 0 to 39, inclusive (think about what rand() actually is and what modulus operator does). Supposed to use std::random_device or so, as it's better at uniform randomization.
4. Should make the generate method of type 'void' and add another parameter, the pointer to the 'thrusters' array. 'thrusters' array should be declared in main.
5. Ideally you want to use more modern C++ structures like vectors for dynamic array -- what you have there is the C-style which comes with limited features and some extra manual management.