This will print out 1(I've pre-incremented i variable) even when condition is false, 'cuz this loop runs code inside it at least once, then it checks condition and if it's true in runs code again, if it's false, it goes farther.
1 2 3 4
int i = 0;
do{
std::cout << ++i;
}while(condition); // with ';', it's important
I am alittle confused as to what kind of condition I would have to include. I am trying to get my output to ask me, "Do you want to run this again Yes/No?"
Condition is eihter true or false. If you want to ask user you can declare variable, ask user and then check if it's yes or no. Condition would be something like this:
1 2 3
do{
...
}while(input == "Yes"); // or anything similar you want
I dropped do { my code
....
} while (input == "Yes");
It told me that input was not in the scope, so after the first open bracket. I created an int input;.....this did not work....Earlier I tried using just a continuous loop by using for ( " " ) but that didn't give the command time enough to read the monthly payment before it started at the beginning
You've got to make variable of the correct type. If you want something like this:
Do you want to continue? y/n y
it would be best if input was a char. If you want this:
Do you want to continue? yes/no no
input can be char array or std::string. It won't know if input = "yes" or if it's equal to "no" until you get answear from the user. You can do it that way:
1 2 3 4 5 6
std::string input;
do{
...
std::cout << "Do you want to continue? yes/no ";
std::cin >> input;
} while (input == "yes");