1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
yawa3891 [41]
4 years ago
12

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;
}
Engineering
1 answer:
chubhunter [2.5K]4 years ago
8 0

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.

You might be interested in
Write a function "funthree" that will print a box of characters. The function will always receive as the first input argument th
stiv31 [10]

Answer: i8g7ieusgr7eytuu7esieso87 sugr7pi8y8hiuh9yehroe998 rydyh9 t9ry9 7 fdgerje 78re87es 7yehr87ehtu9hu7b puuhihugogi;ghi uhugyug fhglhfu fufbiup hughghuihu fhuihihiuhg uhfuhuig8fguh hguihfhjliigihfuhf;gjihgh hfuyt8uyiiohiodohi

Explanation: so first you are going to hyigfgegidii9thdf5dh8yy7 gdiuigp 87hgiuf 8yhijh gihoighhgd

4 0
4 years ago
Since the passing of the Utah GDL laws in 1999:
wlad13 [49]
The answer is b, I hope this helps you
7 0
3 years ago
How do you calculate the rate of heat transfer between two bodies with a small area of physical contact.
gavmur [86]

Answer:

So the rate of heat transfer to an object is equal to the thermal conductivity of the material the object is made from, multiplied by the surface area in contact, multiplied by the difference in temperature between the two objects, divided by the thickness of the material.

3 0
3 years ago
A manager has a list of items that have been sorted according to an item ID. Some of them are duplicates. She wants to add a cod
ruslelena [56]

Answer:

The solution code is written in Python:

  1. items = [{"id": 37697, "code": ""},{"id": 37698, "code": ""},{"id": 37699, "code": ""},{"id": 37699, "code": ""}, {"id": 37699, "code": ""},
  2. {"id": 37699, "code": ""},{"id": 37699, "code": ""},{"id": 37699, "code": ""},{"id": 37700, "code": ""} ]
  3. items[0]["code"] = 1
  4. for i in range(1, len(items)):
  5.    if(items[i]["id"] == items[i-1]["id"]):
  6.        items[i]["code"] = items[i-1]["code"] + 1
  7.    else:
  8.        items[i]["code"] = 1
  9. print(items)

Explanation:

Firstly, let's create a list of dictionary objects. Each object holds an id and a code (Line 1-2). Please note all the code is initialized with zero at the first beginning.

Next, we can assign 1 to the <em>code</em> property of items[0] (Line 4).

Next, we traverse through the items list started from the second element (Line 6). We set an if condition to check if the current item's id is equal to the previous item (Line 7). If so, we assign the previous item's code + 1 to the current item's code (Line 8). If not, we assign 1 to the current item's code (Line 10).

At last, we print out the item (Line 12) and we shall get

[{'id': 37697, 'code': 1}, {'id': 37698, 'code': 1}, {'id': 37699, 'code': 1}, {'id': 37699, 'code': 2}, {'id': 37699, 'code': 3}, {'id': 37699, 'code': 4}, {'id': 37699, 'code': 5}, {'id': 37699, 'code': 6}, {'id': 37700, 'code': 1}]

 

6 0
4 years ago
What country called for a boycott of an E! late-night comedian who made offensive remarks during an Amy Winehouse segment?
olga55 [171]
I’m sry idk but I think it Canada
5 0
4 years ago
Read 2 more answers
Other questions:
  • What is the difference between a Datum and a Datum Feature? a) A Datum and Datum Feature are synonymous. b) A Datum is theoretic
    14·1 answer
  • Which of these is NOT a function of Shock Absorbers?
    15·2 answers
  • What is the difference between gage pressure and absolute pressure?
    12·1 answer
  • Scenario: You and three of your friends decide to hike the Appalachian Trail, a 2175-mile trail running from Georgia to Maine, s
    11·1 answer
  • Un conejo puede recorrer una distancia de 90 m en 7 segundos .Cual es su velocidad?
    5·1 answer
  • Technician A says that a graphing multi-meter may be used to verify signals going to and from electrical and electronic componen
    9·1 answer
  • Why become an Android programmer?
    11·1 answer
  • Tech A says that a mechanical pressure regulator exhausts excess fluid back to the transmission pan. Tech B says that if the tra
    9·1 answer
  • Select three types of variables scientists use in experiments.
    6·2 answers
  • A semiconductor is a material that can carry an electric current between a ______and an insulator
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!