Answer to Question #3324 in C++ for mukunda
2011-07-05T09:22:24-04:00
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.
1
2011-07-11T10:05:48-0400
#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 !
Learn more about our help with Assignments:
C++
Comments
Leave a comment