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
Genrish500 [490]
3 years ago
13

Write a do-while loop that asks the user to enter two numbers. The numbers should be added and the sum displayed. The user shoul

d be asked if he or she wishes to per- form the operation again. If so, the loop should repeat; otherwise it should terminate.
Computers and Technology
1 answer:
iVinArrow [24]3 years ago
5 0

The do-while loop for the given problem is shown below.  

do  

{  

  // user asked to enter two numbers  

  cout<<"Enter two numbers to be added."<<endl;  

  cin>>num1;  

  cin>>num2;  

  sum = num1 + num2;  

 

  // sum of the numbers is displayed  

  cout<<"Sum of the two numbers is "<<sum<<endl;  

  // user asked whether to perform the operation again  

  cout<<"Do you wish to continue (y/n) ?"<<endl;  

   cin>>choice;  

}while(choice != 'n');  

The variables to hold the two numbers and their sum are declared as float so that the program should work well for both integers and floating numbers.

float num1, num2, sum;

The char variable is taken since it holds only a single-character input from the user, 'y' or 'n'.

char choice;

The whole program is given below.

#include <iostream>

using namespace std;

int main() {

float num1, num2, sum;

char choice;  

do  

{  

  // user asked to enter two numbers  

  cout<<"Enter two numbers to be added."<<endl;  

  cin>>num1;  

  cin>>num2;  

  sum = num1 + num2;  

  // sum of the numbers is displayed  

  cout<<"Sum of the two numbers is "<<sum<<endl;  

  // user asked whether to perform the operation again  

  cout<<"Do you wish to continue (y/n) ?"<<endl;  

  cin>>choice;  

}while(choice != 'n');

cout<<"Quitting..."<<endl;

}

You might be interested in
Use the drop-down tool to match each definition to the correct word or phrase. The computer that responds to requests from the c
Lera25 [3.4K]

Answer:

The computer that responds to requests from the client computer:  

Server

Connects network devices or different parts of a network:  

Switch

A piece of equipment that directs data where it should go:  

Router

Connects many different Ethernet devices and allows them to connect to the network with one connection:  

Hub

The computer that uses service provided by a server:  

Client

Explanation:

6 0
3 years ago
11 of the 25 people on the bus get off at the first stop. What percent best represents the portion of the bus that got off on th
miskamm [114]

Answer:

44%

Explanation: First, you have to divided 11 by 25. Which is 0.44. And then you multiply the quotient by 100 to get your percentage.

5 0
3 years ago
Find the number of ideal integers within the given segment [low,high] inclusive. An ideal number is a positive integer that has
Alex Ar [27]

Answer:

  1. low = 10
  2. high = 50
  3. count = 0
  4. for i in range(low, high + 1):
  5.    if(i % 3 == 0 and i % 5 == 0):
  6.        count += 1
  7. print(count)

Explanation:

The solution code is written in Python.

We can create low and high variables to store the lower bound and upper bound in the range (Line 1-2)

Next create a counter variable, count (Line 3).

Use a for loop to traverse through the number between lower bound and upper bound and check if the current number-i is divisible by 3 and by 5, increment the count by one.

After the loop, print the count and we can get the number of ideal integers within the range (Line 8).

6 0
3 years ago
Which of the following experiences is considered a simulation?
Butoxors [25]

Answer:

c

Explanation:

3 0
3 years ago
What are the basic steps in creating a new program
ladessa [460]
<span>first make a text file, then write the framework or(scripts for your program). Then write Your Instruction and save Your Program. After you've done that, get and install java jdk(its like a development tool). Finally c<span>opy the path(text file) to the Java tools(jdk)

</span></span>
3 0
3 years ago
Other questions:
  • Is a collection of limited versions of Microsoft office programs
    10·1 answer
  • A plan to budget time for studying and activities is referred to as
    15·1 answer
  • Write a Temperature class that will hold a temperature in Fahrenheit, and will provide methods to get and display the temperatur
    5·1 answer
  • What command is used to generate an RSA key pair?
    9·1 answer
  • How does this app work?
    11·2 answers
  • Does anyone have the GCSE 2018 Design Technology J310/01 practice paper?
    15·1 answer
  • What the meaning of ethics
    14·1 answer
  • In a Microsoft Office application, what is the area at the bottom of the application screen that contains information about the
    13·1 answer
  • Explain the Decision making statement​
    15·1 answer
  • Which is the following should be selected in the paragraph dialogue box to prevent page break from occurring within a paragraph
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!