If I have a Do, While statement. How do I make this repeat and output ten times?
I know it is repeating until the condition is met, but how do I do this an additional nine times?
For example,
do
{
stufffffff
cout << this is your answer! << endl;
}
Even for this scenario? This do while runs until it meets the condition and gives an answer. I just want to do ten scenarios of this. Ten different answers from ten instances of this run.
#include <iostream>
# include <time.h>
usingnamespace std;
int main()
{
int maximum;
int minimum;
int random_number;
int req_subtraction;
int current_total;
int total;
cout << "Total Limit?" << endl; //can't go over this
cin >> total;
cout << "Max you can add?" << endl;
cin >> maximum;
cout << "Minimum you can add?" << endl;
cin >> minimum;
cout << "Required Subtraction?" << endl;
cin >> req_subtraction;
srand(time(0)); //seed the random number
int high=maximum;
int low=minimum;
do
{
random_number = rand () % (high - low + 1) + low;//random number between max and min
cout << "Random Number is " << random_number << endl;
current_total += random_number - req_subtraction;
if(current_total < 0) //make so negatives equal out to zero
{
current_total = 0;
}
cout << "The current total is " << current_total << endl;
}
while (current_total < total);
system("pause");
return 0;
}