answer.
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]
1 year 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]1 year 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
Alice just wrote a new app using Python. She tested her code and noticed some of her lines of code are out of order. Which princ
LenKa [72]

Answer:

This is Elijah from FLVS hihi :DDDDDDDDDDDDDDDDDDDDDDDDDDDDD CVS

Explanation:

6 0
2 years ago
An attack in which the attacker attempts to impersonate the user by using his or her session token is known as:
svetoff [14.1K]

Answer:

Session hijacking

Explanation:

Session hijacking : Session hijacking is an attack where a user session is taken over by an attacker. A session starts when you log into a service, for example your banking application, and ends when you log out.

5 0
1 year ago
In 5–10 sentences, describe the procedure for sending an e-mail message.<br> Please HELP!!!!!
horrorfan [7]
P<span>rocedure for sending an e-mail message:
1. On the email website, click "compose".
2. You can see blank spaces for "to" and "message". CLick "to" to the person you need to send an email to and then "message" for the content of your message.
3. After composing a message, click send.</span>
7 0
2 years ago
Kathy is a senior teacher in her school. She is conducting a group discussion between parents and teachers. Her role is to ensur
Fynjy0 [20]
She is the leader of the discussion
3 0
1 year ago
Read 2 more answers
Survey Q. Non-scoring: If you are working in a customer facing agile team, who is more mature/ready for Agile? (1 correct answer
fomenos

I think that 3 would be the correct answer

8 0
2 years ago
Read 2 more answers
Other questions:
  • Which of the following word pairs correctly completes the sentence below?
    15·2 answers
  • A(n) _____ is the highest educational degree available at a community college. master bachelor associate specialist
    13·2 answers
  • 1. Do you consider Facebook, MySpace, and LinkedIn forms of disruptive or sustaining technology? Why?
    15·1 answer
  • Big Data often involves a form of distributed storage and processing using Hadoop and MapReduce.
    12·1 answer
  • Which of the following code is correct? I: print("Programming is fun") print("Python") print("Computer Science") II: print("Prog
    11·1 answer
  • In the Budget Details sheet, if you wish to autofill with the formula, you must use a ______ reference for the LY Spend Total ce
    10·1 answer
  • Assign test_stat_72 to the value of the test statistic for the years 1971 to 1973 using the states in death_penalty_murder_rates
    11·1 answer
  • The variable grade can have any real number value from 0 to 100. Ask the user to enter a grade in numerical form. Write an if-el
    9·1 answer
  • Given input characters for an arrowhead and arrow body, print a right-facing arrow. Ex: If the input is: *
    14·1 answer
  • What does NOT match with Agile Manifesto?
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!