60 526
Assignments Done
97,8%
Successfully Done
In April 2018

Answer to Question #3324 in C++ for mukunda

Question #3324
Write a program to print the desired output when you give an input as 1 to add, 2 to multiply, 3 to subtract using switch.
Expert's answer
#include <iostream>
using namespace std;

int main()
{
int num1 = 10, num2 = 23;

cout << "A = " << num1 << ", B = " << num2 << endl;
cout << "Please choose: 1(add), 2(multiply), 3(substract):" << endl;

int choice = -1;
cin >> choice;

int result = 0;
switch (choice) {
& case 1: result = num1 + num2; break;
& case 2: result = num1 * num2; break;
& case 3: result = num1 - num2; break;
}
cout << "Result is " << result << endl;
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 first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions