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
A regular polygon is an n-sided polygon in which all sides are of the same length and all angles have the same degree (i.e.,the
butalik [34]

import java.util.Scanner;

public class polygon {

/** Main Method */

public static void main(String[] args) {

 Scanner input = new Scanner(System.in); // Create a Scanner

 // Prompt the user to enter the number of sides  

 // and the side of a regular polygon

 System.out.print("Enter the number of sides: ");

 int n = input.nextInt();

 System.out.print("Enter the side: ");

 double side = input.nextDouble();

 // Display the area of the regular polygon

 System.out.println("The area of the polygon is " + area(n, side));

}

/** Method area computes and returns the area of a regular polygon */

public static double area(int n, double side) {

 return (n * Math.pow(side, 2) / (4 * Math.tan(Math.PI / n)));

}

}

4 0
3 years ago
In a ___ traversal of a binary tree, you begin at the root and visit nodes one level at a time
svp [43]

Answer:

The answer of the given question is Inorder.

Explanation:

In the inorder traversal the binary tree start from the root and visited all the vertex in the tree .

The inorder follow the following Algorithm

1. Traverse in the left subtree.

2 Print the data (visit the node ).

3 Traverse in the Right subtree.

8 0
3 years ago
What steps can you take to secure your private information?.
pogonyaev

Answer:

Below:

Explanation:

1. Practice mail security. Use a public mailbox rather than your home mailbox to send bill payments and other mail containing sensitive information. Pick your mail up promptly and ask the post office to hold it while you’re away.

2. Guard your Social Security number. Don’t carry your Social Security card, military ID, Medicare, or other cards that have your Social Security number on them unless you are going somewhere where you will need them. Only provide your Social Security number when there is a legitimate need to do so.

3. Lock and shred. Keep your billing and banking statements and other personal records locked up and shred them when no longer needed.

4. Stop prescreened credit and insurance mailings. Call toll-free 1-888-567-8688 to get off mailing lists for credit and insurance offers. Your Social Security number will be required. This keeps thieves from intercepting and accepting the offers in your name and doesn’t affect your eligibility for credit or insurance.

5. Keep private information to yourself. Never respond to phone calls or emails asking to confirm your Social Security number or account numbers. Don’t leave PIN numbers, passwords or other personal information around for others to see.

6. Be safe online. Use anti-virus and anti-spyware software and a firewall on your computer and keep them updated. When you provide financial or other sensitive information online, the address should change from “http” to “https” or “shttp.” A symbol such as a lock that closes may also indicate that the transmission is secure.

7. Look at your bills and bank statements promptly. If you find any charges or debits that you never made, contact the bank or company immediately.

Hope it helps.......

It's Muska...  

6 0
2 years ago
Float in is an example of a(n) _____. annotation, evolution, animation, simulation
Pavel [41]
Animation or C your welcome my friend
7 0
3 years ago
Jorge is looking for information about the life of his favorite music artist, Ray Charles. Which type of resource(s) would provi
Bumek [7]
He could read a biography.
4 0
2 years ago
Other questions:
  • What does delegating access give someone the permission to do on behalf of the user? Choose two answers.
    5·1 answer
  • What types of automation device might require specialist installer training?
    5·1 answer
  • What can web designers use to control the individual web page layouts for all of the pages on a website?
    7·1 answer
  • True or false: when considering data backups, it is most important to verify that the integrity of the backup file or data is va
    9·1 answer
  • Drag the tiles to the correct boxes to complete the pairs.
    13·1 answer
  • What is the best brand of folders
    13·2 answers
  • Intelligence is to creativity as _____ is to _____. Group of answer choices spatial intelligence; musical intelligence correct t
    15·1 answer
  • Which object event is an indication that something has been created but not committed into the database?
    13·1 answer
  • Dominic's teacher asked him to create a chart or graph to compare the different grade levels in the school's FBLA club. Which ch
    5·2 answers
  • Sebutkan contoh komputer analog, komputer digital, dan komputer hybrid
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!