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
JulijaS [17]
3 years ago
15

Write a program which accepts two integers from the user. Then it asks the user what he wants to do with those two numbers. If t

he user choice is
‘A’ – Add the two numbers

‘B’ – Subtract the second number from the first number

‘C’ – Multiply the first number by the second number

‘D’ – Divide the first number by the second number

‘Q’ – End the operation

Your program should continue to accept the two numbers and the user choice unless the user enters ‘Q’ as choice.
Computers and Technology
1 answer:
il63 [147K]3 years ago
3 0

Answer:

// program in C++.

#include <bits/stdc++.h>

using namespace std;

// function to print choice menu

void menu()

{

   cout<<"A – Add the two numbers:"<<endl;

   cout<<"B – Subtract the second number from the first number:"<<endl;

   cout<<"C – Multiply the first number by the second number:"<<endl;

   cout<<"D – Divide the first number by the second number:"<<endl;

   cout<<"Q – End the operation:"<<endl;

}

// driver function

int main()

{

// variables

int x,y;

char ch;

int flag=1;

do{

   cout<<"Enter first number:";

   // read first number

   cin>>x;

   cout<<"Enter second number:";

   // read second number

   cin>>y;

   // call menu function

   menu();

   cout<<"Enter your choice:";

   // read choice

   cin>>ch;

   switch(ch)

   {

       case 'A':

       case 'a':

       cout<<"Addition of two numbers is:"<<(x+y)<<endl;

       break;

       case 'B':

       case 'b':

       cout<<"Subtract the second from the first is:"<<(x-y)<<endl;

       break;

       case 'C':

       case 'c':

       cout<<"Multiplication of two numbers is:"<<(x*y)<<endl;

       break;

       case 'D':

       case 'd':

       cout<<"Division the first by the second is:"<<(x/y)<<endl;

       break;

       case 'Q':

       case 'q':

       flag=0;

   }

   if(flag==0)

   break;

   

}while(ch!='Q'||ch!='q');

return 0;

}

Explanation:

Read two numbers from user.Then read the choice for operation on both the numbers. Then print the choices of operation by calling menu() function.If choice is "A"  then print Addition of both.if choice is "B" then print subtraction of second from  first number.if choice is "C" then print the multiplication of both numbers.If choice is "D" then print division of first by second.If the choice is "Q" then quit the operation. Repeat this until user's choice is "Q".

Output:

Enter first number:6                                                                                                      

Enter second number:2                                                                                                      

A – Add the two numbers:                                                                                                  

B – Subtract the second number from the first number:                                                                      

C – Multiply the first number by the second number:                                                                        

D – Divide the first number by the second number:                                                                          

Q – End the operation:                                                                                                    

Enter your choice:A                                                                                                        

Addition of two numbers is:8                                                                                              

Enter first number:8                                                                                                      

Enter second number:2                                                                                                      

A – Add the two numbers:                                                                                                  

B – Subtract the second number from the first number:                                                                      

C – Multiply the first number by the second number:                                                                        

D – Divide the first number by the second number:                                                                          

Q – End the operation:                                                                                                    

Enter your choice:Q      

You might be interested in
Display all the natural numbers from 1 to 100 that are exactly divisible by 3 and 7 using FOR … NEXT. Without using Mod
Tcecarenko [31]

Answer:

FOR i% = 1 TO 100

 IF ((i%\3) = i%/3) AND ((i%\7) = i%/7)  THEN

   PRINT i%

 END IF

NEXT i%

Explanation:

Of course using MOD would be cleaner, but another way to check if a number is integer divisable is to compare the outcome of an integer division to the outcome of a floating-point division. If they are equal, the division is an integer division.

The program outputs:

21

42

63

84

6 0
3 years ago
What is the main advantage that a website builder offers for web development?
Trava [24]
The correct answer is: OA. It enables people with no coding skills to create websites.
4 0
3 years ago
Read 2 more answers
Help to how to write pseudo code to insert a new node to Binary Search Tree. Using C++.
dimulka [17.4K]

Answer:

Let the function be Node* ins(Node *root,int k)

if root node is NULL then return new node with data equal to k.

If the k <root->data

root->left=ins(root->left,k);

else if k >root->data

root->right =ins(root->right,k);

At last return root.

Explanation:

Node is always inserted at the at the leaf node.We will search k in the tree if we hit a the leaf node the new node is inserted as the child of the leaf node.

4 0
2 years ago
What technical was the microscope invented in?
Ilia_Sergeevich [38]

Answer:

Two Dutch spectacle-makers and father-and-son team, Hans and Zacharias Janssen, create the first microscope in 1590.

Explanation:

A microscope is an instrument that makes an enlarged image of a small object, thus revealing details too small to be seen by the unaided eye. The most familiar kind of microscope is the optical microscope, which uses visible light focused through lenses. Eeuwenhoek observed animal and plant tissue, human sperm and blood cells, minerals, fossils, and many other things that had never been seen before on a microscopic scale. He presented his findings to the Royal Society in London, where Robert Hooke was also making remarkable discoveries with a microscope.

8 0
2 years ago
Why is the cpu the most important component in a computer?
german
CPU (Central Processing Unit) is also known as the brain of the computer because this is the place which actually runs the programs. The programs are the set of instructions needed to perform a task.
4 0
2 years ago
Other questions:
  • A technician is troubleshooting a computer that will not communicate with any hosts on the local network. While performing a vis
    9·1 answer
  • In which part of a browser will you type the url of a website
    11·1 answer
  • Which of the following is defined as the elastic leasing of pooled computer resource over the Internet? 1) Broadband 2) Wiki 3)
    13·1 answer
  • If you want to conserve ink or toner, you can instruct powerpoint to print ____ documents.
    6·1 answer
  • Operating systems provide a measure of security by allowing users to access to those resources they've been cleared to use as we
    8·1 answer
  • When powering up a home network, make sure all computers and peripherals are turned on before turning on the modem/router?
    11·1 answer
  • What are the differences, physically and logically, between the two printing configurations: Network-attached Printing and Netwo
    7·1 answer
  • Consider the following code snippet:
    13·1 answer
  • Which of the following technologies is an example of social media
    12·1 answer
  • A person's oral communication skills can give either a positive or negative first impression.
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!