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
creativ13 [48]
4 years ago
14

2. Design a Do-While loop that asks the user to enter two numbers. The numbers should be added and the sum displayed. The loop s

hould ask the user whether he or she wishes to perform the operation again. If so, the loop should repeat; otherwise it should terminate.
Computers and Technology
2 answers:
Ugo [173]4 years ago
4 0

#include <iostream>

#include <string>

main ()

{

   using std::cout;

   using std::cin;

   std::string s;

   do

   {

      cout<<"Type 2 numbers: ";

      int a,b;

      cin>>a>>b;

      cout<<"Sum of your numbers equals to: "<<a+b;

      cout<<"\nType \"Yes\" if you want to continue.";

      cin>>s;

   }while(s=="Yes");

   return 0;

}

qwelly [4]4 years ago
3 0

Answer:

Program :

#include <iostream> // Header file.

using namespace std;

int main () // Main function which starts the executions

{

   int First_Number,Second_Number; // variable declaration.

   char choice; // Variable declaration.

   do // do while loop

   {

        cout<<"Enter two number for addition"; // user instruction

        cin>>First_Number>>Second_Number; // take a input

        cout<<"The adition of "<<First_Number<<" and "<<Second_Number<<" is: "<<First_Number+Second_Number; //Addition will print

        cout<<"\nType \"Y\" for continue the operation again otherwise press any key"; // User message for choice.

        cin>>choice; // input for choice.

   }

   while(choice=='Y'||choice=='y'); // condition for Do-While loop

   return 0; // return statement.

}

Output:

  • If the user input are 4,5 and u then the output is 9
  • If the user input are 5,6 and y and 7,8 and u then the output are 11, 15.

Explanation:

  • The above code is in C++ language.
  • The above program firstly renders a message to enter the two numbers.
  • Then it performs addition operation and then the result will be printed.
  • Then it renders a message for the user choice.
  • If the user enters capital y or small y, then the above operation will continue again.
  • Otherwise, the program will be terminated.
You might be interested in
What are the two methods of creating a folder​
son4ous [18]

Answer:

1. right click empty space, go to New, and click New Folder

2. press Ctrl + Shift + N

Explanation:

5 0
2 years ago
What do you need to do before you can sort and filter data in a database?
Airida [17]
You need to first format the table becfor you can sort and filter data in a <span>database. ♥</span>
5 0
3 years ago
Which magazine can help public determine best technology to buy
Dennis_Churaev [7]
Consumer report would help determine the best technology to buy.
4 0
3 years ago
What is the diameter of #12 gage copper wire
Helga [31]
The diameter would be 0.0808 in inches and 2.053 in millimeters. Hope this helps.
6 0
3 years ago
How does the mass of a payload affect the accuracy and the distance of a catapult?
myrzilka [38]
The 3 primary energy storage mechanisms are tension, torsion & gravity.
5 0
4 years ago
Other questions:
  • Annabeth has been using a public cloud to store and access her documents. Which drawback of a public cloud should she be aware o
    11·1 answer
  • Who are the founders of the video-sharing site Blip?
    8·1 answer
  • How to know if somebody else is listening my conversations by cellphone?
    13·1 answer
  • Chris wants to guarantee that the instructions within the loop are executed one time regardless of thestatus of a condition. Whi
    9·1 answer
  • Can you please help me at question two
    13·1 answer
  • What letter names the drive where windows most commonly stores data and files
    13·1 answer
  • Write a C program to compute the average age of nth student
    13·1 answer
  • Which of the following is not a characteristic of a motorcycle?
    6·1 answer
  • COMPUTER FUNDIMENTAL HELP 20 POINTS!!!
    5·1 answer
  • Methods are used to define an object's behavior. True False
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!