Ask Question

Write a do-while loop that continues to prompt a user to enter a number less than 100, until the entered number is actually less than 100. End each prompt with a newline. Ex: For the user input 123, 395, 25, the expected output is:

Enter a number (<100):

Enter a number (<100):

Enter a number (<100):

Your number < 100 is: 25

c++

#include

using namespace std;

int main () { int userInput = 0;

do

cout << "Your number < 100 is: " << userInput << endl;

return 0;

}

+4
Answers (1)
  1. 10 March, 07:34
    0
    The following do while loop is given below

    do

    {

    cout << "Enter a number (<100) : "; / / print the message

    cin >> userInput; / / Read the number by user

    }while (userInput>100); / / checking the condition

    Explanation:

    Following are the description of above statement

    In the above do-while loop print the message "Enter a number (<100) : " by using the cout function. The cout function in C+ + is used to display the number or message in the console window. Read the Number by user in "userInput" variable by using cin function. Finally check the condition by greater than 100. This loop will continue if the user reads the number greater then 100. If the user enters the number less then 100 the execution of the loop will stop.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “Write a do-while loop that continues to prompt a user to enter a number less than 100, until the entered number is actually less than 100. ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers