# Answer to Question #29627 in C++ for Rose

Question #29627

Develop a menu-driven program that inputs two numbers and, at the user's options, find their sum, difference, product, or quotient.

Expert's answer

#include <iostream>

#include <conio.h>

using namespace std;

//main function

int main()

{

//variables

float fisrtnumber;

float secondnumber;

float sum;

float difference;

float product;

float quotient;

int ch;//choice

//input fisrt number and second number

cout<<"Enter first number: ";

cin>>fisrtnumber;

cout<<"Enter second number: ";

cin>>secondnumber;

do{

//show menu

cout<<"

1 - sum";

cout<<"

2 - difference";

cout<<"

3 - product";

cout<<"

4 - quotient";

cout<<"

5 - exit";

cout<<"Enter one menu item:";

cin>>ch;

switch(ch){

case 1:

sum=fisrtnumber+secondnumber;//find sum

cout<<"Sum = "<<sum<<"

";//show sum

break;

case 2:

difference=fisrtnumber-secondnumber;//find difference

cout<<"Difference =

"<<difference<<"

";//show difference

break;

case 3:

product=fisrtnumber*secondnumber;//find product

cout<<"Product =

"<<product<<"

";//show product

break;

case 4:

quotient=fisrtnumber/secondnumber;//find quotient

cout<<"Quotient =

"<<quotient<<"

";//show quotient

break;

}

}while(ch!=5);//exit

return 0;

}

#include <conio.h>

using namespace std;

//main function

int main()

{

//variables

float fisrtnumber;

float secondnumber;

float sum;

float difference;

float product;

float quotient;

int ch;//choice

//input fisrt number and second number

cout<<"Enter first number: ";

cin>>fisrtnumber;

cout<<"Enter second number: ";

cin>>secondnumber;

do{

//show menu

cout<<"

1 - sum";

cout<<"

2 - difference";

cout<<"

3 - product";

cout<<"

4 - quotient";

cout<<"

5 - exit";

cout<<"Enter one menu item:";

cin>>ch;

switch(ch){

case 1:

sum=fisrtnumber+secondnumber;//find sum

cout<<"Sum = "<<sum<<"

";//show sum

break;

case 2:

difference=fisrtnumber-secondnumber;//find difference

cout<<"Difference =

"<<difference<<"

";//show difference

break;

case 3:

product=fisrtnumber*secondnumber;//find product

cout<<"Product =

"<<product<<"

";//show product

break;

case 4:

quotient=fisrtnumber/secondnumber;//find quotient

cout<<"Quotient =

"<<quotient<<"

";//show quotient

break;

}

}while(ch!=5);//exit

return 0;

}

Need a fast expert's response?

Submit orderand get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

## Comments

## Leave a comment