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
Explain why the cosmic horizon is much smaller than the universe itself
sashaice [31]
The cosmic horizon is what your eye allows you to see, and that is only a small fragment of the universes actual size
3 0
3 years ago
Explain the advantages of taking the aspire test
Len [333]

<span>The Aspire test plan is similar to the ACT </span>plan but they have different goals and format. The ACT was simply a readiness test and seeks to assess your academic progress. The Aspire, on the other hand, focuses more on critical and creative thinking. It is a good way to judge your progress but it won’t affect your applications to college admissions and scholarship.

8 0
4 years ago
Assume that programs spend about 25% of their time waiting for I/O operations to complete. If there are FOUR programs loaded int
natima [27]

Answer:

0.9961

Explanation:

Given that:

Proportion of time waiting for I/O operation to complete = 25% = 0.25

Number of programs waiting in memory = 4

Using the CPU Utilization formula :

CPU Utilization = 1 - p^n

1 - 0.25^4

1 - 0.00390625

0.99609375

5 0
3 years ago
A threat actor has successfully breached the network firewall without being detected by the IDS system. What condition describes
Mamont248 [21]

Answer:

false negative

Explanation:

A false negative is a dangerous state in which the IDS (Intrusion Detection System) assumes the activity as acceptable in which the activity is actually an attack occurred on the system.

That means, the Intrusion Detection System has failed to catch the attack. This is the most dangerous state, as the systems were compromised and the network or cyber security people were unable to find the attack.

More generally, there are two types of Intrusion Detection Systems ( IDS ). Network based IDSs ( NIDS ) and Host based IDSs ( HIDS ).

5 0
4 years ago
You are creating a story map about Mexico. After configuring the web app template, you launch the app to test it. When the app o
navik [9.2K]
Nbdjsksjsidjdjwkwejd
3 0
3 years ago
Other questions:
  • A ________ is a small text file passed to a web browser on a user's computer by a web server.
    7·1 answer
  • On an Android device, where can a user find the correct app to use to sync contacts and apps among devices?
    10·1 answer
  • _____ are unique identifiers of computer or network addresses on the internet.
    6·2 answers
  • In server-side discovery pattern, load balancing and routing of the request to the service instances are taken care of by the se
    9·1 answer
  • Which of the following sentences uses correct punctuation? A. I am a good communicator, and I am a strong team member. B. I comm
    12·2 answers
  • 16 to 19 year old drivers are how many more times likely to crash? 1.7,2.7,0.7 ,3.7
    12·2 answers
  • Imagine you are responsible for making a presentation that includes a representation of the logic flow through a process. You un
    11·1 answer
  • Which of the following happens when you enter the formula =G15 into a cell?
    12·1 answer
  • Information systems cannot solve some business problems. Give three examples and explain why technology cannot help
    11·1 answer
  • Chloe is creating the software requirements specifications (SRS) for a project. The project is a web app that allows students to
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!