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
Rate monotonic Analysis (RMA) is a model for predicting whether or not a system will meet its timing as well as throughput requi
barxatty [35]
Trygsgsysuduzududuuxucufudududiff
8 0
3 years ago
The move up only one line in Microsoft Word, use the following method: (a) press Ctrl + Home Keys (b) Press Home Keys (c) Press
FinnZ [79.3K]

Answer:

(d) Press Up Arrow Keys

Explanation:

(a) press Ctrl + Home Keys

  • Incorrect

(b) Press Home Keys

  • Incorrect

(c) Press Ctrl + Up Arrow Keys

  • Incorrect

(d) Press Up Arrow Keys

  • Correct
7 0
3 years ago
Which of the following are good ways to keep your information and your computer secure?
Assoli18 [71]

Answer:

the correct answer is E

I do all of these so I would assume E

4 0
3 years ago
Read 2 more answers
Justify the need for branching and jump codes in the instruction set using real world scenarios
topjm [15]

Answer:

As in the real world, people using a program would provide different inputs, that would require different outputs. For example in a traffic light system, there could be a function that constantly checks for if the button is pressed. When the button is pressed the traffic light loop would branch out of its current running code in order to turn the lights to red, and allow the pedestrians to cross.

8 0
3 years ago
PLEASE HELP ASAP!!!!!!!!!!!
Bingel [31]

Answer:

True

Explanation:

3 0
3 years ago
Read 2 more answers
Other questions:
  • Which relationship is possible when two tables share the same primary key?
    9·2 answers
  • What is &lt;html&gt;
    9·2 answers
  • Write a program that uses a two dimensional array to store the highest and lowest temperatures for each month of the calendar ye
    10·1 answer
  • What could break the circuit between your home and an electric power plant?
    15·2 answers
  • Describe the use of technology in the promotional function
    5·2 answers
  • You are assigned to modify an existing Webpage by adding several tables that contain precise wording. The Webpage has had severa
    14·1 answer
  • An art board on which text and graphics are pasted is known as a __?
    12·1 answer
  • Many loop control variable values are altered by ____ or adding to them
    11·1 answer
  • In a paragraph of no less than 125 words, explain what netiquette is and how it improves efficiency and productivity in the work
    14·1 answer
  • Which of the following is true of lossy and lossless compression techniques?
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!