Anonymous School
(Minds of Hacker)
--------------------------------
Program to create a simple calculator using switch case.
#include <iostream>using namespace std;int main(){float num1, num2,sub,add,multi,divi;int choose;cout << "Enter the values\n";cin >> num1 >> num2;while (1){cout << "\n\nChoose the options\n1)Add\n2)Sub\n3)Multiplection\n4)Division\n5)Exit\n\n";cin >> choose;switch (choose){case 1:add = num1 + num2;cout << "Addition = " << add;break;case 2:sub = num1 - num2;cout << "Subtraction = " << sub;break;case 3:multi = num1 * num2;cout << "Multiplection = " << multi;break;case 4:divi = num1 / num2;cout << "Division = " << divi;break;case 5:return 0;break;default:cout << "Invalid option ";break;}}}
Output:
Enter the values
30
20
Choose the options
1)Add
2)Sub
3)Multiplection
4)Division
5)Exit
1
Addition = 50
Choose the options
1)Add
2)Sub
3)Multiplection
4)Division
5)Exit
*******************Don't Make Learning Hard*****************
Follow us on :-
1) YouTube Channel :- Click Here
2) Blog :- Click Here