Answer to Question #17550 in C++ for Candice Battle

Question #17550
Develop a menu-driven program that inputs two numbers and, at the user’s option, finds their sum, difference, product, or quotient. Please give a example.
1
Expert's answer
2012-10-30T12:50:36-0400
#include <iostream>
#include <conio.h>
using namespace std;

int main ()
{
intchoice;
do{
system("cls");
cout<< "1) +" << endl;
cout<< "2) -" << endl;
cout<< "3) *" << endl;
cout<< "4) /" << endl;
cout<< "5) Exit" << endl;
cin>> choice;
if(choice == 1) {
system("cls");
intfirst, second;
cout<< "Enter first number: " << endl;
cin>> first;
cout<< "Enter second number: " << endl;
cin>> second;
cout<< "Result: " << first + second << endl;
system("pause");
}
elseif (choice == 2) {
system("cls");
intfirst, second;
cout<< "Enter first number: " << endl;
cin>> first;
cout<< "Enter second number: " << endl;
cin>> second;
cout<< "Result: " << first - second << endl;
system("pause");
}
elseif (choice == 3) {
system("cls");
intfirst, second;
cout<< "Enter first number: " << endl;
cin>> first;
cout<< "Enter second number: " << endl;
cin>> second;
cout<< "Result: " << first * second << endl;
system("pause");
}
elseif (choice == 4) {
system("cls");
doublefirst, second;
cout<< "Enter first number: " << endl;
cin>> first;
cout<< "Enter second number: " << endl;
cin>> second;
cout<< "Result: " << first / second << endl;
system("pause");
}
}while (choice != 5);
system("pause");
return0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS