Answer:
#include <iostream>//including iostream library to use functions such as cout and cin
using namespace std;
int main() {
int userInput = 0;
do
{
cout << "Enter a number < 100: " ;
cin >> userInput;
if (userInput < 100)//condition if number is less than 100
{
cout << "Your number < 100 is: " << userInput << endl;
}
} while (userInput > 100);//do while loop condition
return 0;
}
Explanation:
A do-while loop executes regardless in the first iteration. Once it has run through the first iteration, it checks if the condition is being met. If, the condition is TRUE, the loop begins the second iteration. If FALSE, the loop exits. In this case, the condition is the userInput. after the first iteration, lets say the userInput is 120, the condition userInput > 100 is true.Therefore, the loop will run again until eventually the number is less than hundred, lets say 25. In that case the condition would be 25 > 100, which would be false, so the loops will break.