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]
2 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]2 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
Skylar is viewing her personal and business calendar in a side-by-side fashion, but she would like to view a single calendar tha
pogonyaev

Answer:

The solution for the current situation in which Skylar is viewing her personal and business calendar in a side-by-side fashion, but she would like to view a single calendar that has appointments and meetings from both personal and business. is:

Configure the Overlay option.

Explanation:

The reasons behind this answer are that in the first place, creating another calendar is too much work. In the second place, the share of the calendars is not going to help her because that would only allow someone else to watch her calendars. However, using the overlay option will allow her to mix them and create one calendar with all her information.

8 0
2 years ago
Lai worked on a global team for an American company, and all her work had to be completed in her second language, English. Somet
N76 [4]

Answer:

E) Encoding.

Explanation:

Communication is important aspect of life.Communication barriers occurs at all stages of communication from when the sender sends the message to the receiver receiving the message. Lack of communication skill in that particular comes in encoding barrier.So we conclude that the answer is Encoding.

4 0
2 years ago
Read 2 more answers
An attacker has been successfully modifying the purchase price of items purchased on the company's web site. The security admini
Kruka [31]

Answer:

Form the given statement i have come to know that the by changing hidden form values attacker has been able to modify the purchase price.

Explanation:

User can change a hidden field is not different from a common field from browser or server side.

If you want to store data then user must have to store them on server -side on a session and it is a fastest way.

8 0
2 years ago
Consider the following sequence of instructions:
omeli [17]

Answer:

i think the answer is c hope this helps!!!!!

Explanation:

8 0
2 years ago
Read 2 more answers
Assume that k corresponds to register $s0, n corresponds to register $s2 and the base of the array v is in $s1. What is the MIPS
BlackZzzverrR [31]

Answer:

hello your question lacks the C segment so here is the C segment

while ( k<n )

{v[k] = v[k+1];

     k = k+1; }

Answer : while:

   bge $s0, $s2, end   # while (k < n)

   addi $t0, $s0, 1    # $t0 = k+1

   sll $t0, $t0, 2     # making k+1 indexable

   add $t0, $t0, $s1   # $t0 = &v[k+1]

   lw $t0, 0($t0)      # $t0 = v[k+1]

   sll $t1, $s0, 2     # making k indexable

   add $t1, $t1, $s1   # $t1 = &v[k]

   sw $t0, 0($t1)      # v[k] = v[k+1]

   addi $s0, $s0, 1

   j while

end:

Explanation:

The MIPS assembly code corresponding to the C segment is

while:

   bge $s0, $s2, end   # while (k < n)

   addi $t0, $s0, 1    # $t0 = k+1

   sll $t0, $t0, 2     # making k+1 indexable

   add $t0, $t0, $s1   # $t0 = &v[k+1]

   lw $t0, 0($t0)      # $t0 = v[k+1]

   sll $t1, $s0, 2     # making k indexable

   add $t1, $t1, $s1   # $t1 = &v[k]

   sw $t0, 0($t1)      # v[k] = v[k+1]

   addi $s0, $s0, 1

   j while

end:

4 0
2 years ago
Other questions:
  • Which statement best describes how the rapid prototyping model works?a) Developers create prototypes to show stakeholders how va
    11·2 answers
  • Represent decimal number 8620 in (a) BCD, (b) excess-3 code, (c)2421 code, and (d) as a binary number
    7·1 answer
  • Explain why types of technology valued can vary
    5·2 answers
  • Where is the Name Manager dialog box found?
    13·1 answer
  • In what year were graphical user interfaces (GUIs) pioneered? 1969 1974 1991 2001
    12·2 answers
  • a. STOP: What is a technology habit you practice today that you now realize will not help you to be successful? Explain why it’s
    13·2 answers
  • You need to design a data storage scheme for Hayseed Heaven library data system. There are several hundred thousand large data r
    8·1 answer
  • In the lab, you discovered that the server you scanned (10.20.1.2) was vulnerable to the WannaCry ransomeware attack. What ports
    15·1 answer
  • 1. What are the first tasks the Team Leader (TL) must perform after arriving at the staging area?
    15·1 answer
  • You know that you should check the room for security against unwanted entry do you check locks on doors and windows. What else d
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!