Answer to Question #266510 in C++ for Wendy

Question #266510

Create C++ full program where a user enter two numbers, after a menu should prompt a user to

decide whether to:

i. Add

ii. Divide

iii. Subtract

iv. Multiply and

v. Exit


1
Expert's answer
2021-11-16T07:44:58-0500
#include <iostream>


using namespace std;


int main()
{
    int n1,n2,choice,result;


    cout << "Enter the first number" << endl;
    cin>>n1;
    cout << "Enter the second number" << endl;
    cin>>n2;
    cout << " 1. Add" << endl;
    cout << " 2. Divide" << endl;
    cout << " 3. Subtract" << endl;
    cout << " 4. Multiply" << endl;
    cout << " 5. Exit"<<endl;
    cout <<  "Choose from the menu above"<<endl;
    cin>>choice;


    switch (choice)
    {


    case 1:
    result=n1+n2;
    cout<<"The result is: "<<result<<endl;
    break;
    case 2:
      result=n1/n2;
       cout<<"The result is: "<<result<<endl;
    break;
    case 3:
    result=n1-n2;
     cout<<"The result is: "<<result<<endl;
    break;
    case 4:
    result=n1*n2;
     cout<<"The result is: "<<result<<endl;
    break;
    case 5:
    break;
    }
    return 0;
}

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