-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcalculation.cpp
More file actions
42 lines (37 loc) · 1.09 KB
/
Copy pathcalculation.cpp
File metadata and controls
42 lines (37 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// ================================================
// Language: C++ / Cpp
// Topic : [Switch-Case//
// Problem : 👉👉The calculator should input two numbers and an operator from user.
//
// Want : Ques: Write a program to create a calculator th performs basic arithmetic
// operations (add, subtract, multiply and divide) using switch case
// The calculator should input two numbers and an operator from user.
//
// ================================================
#include <iostream>
using namespace std;
int main()
{
int n1 , n2;
char op;
cout << "Enter two numbers: ";
cin >> n1 >> n2;
cout << "Enter operator (+, -, *, /): ";
cin>>op;
switch (op)
{
case '+':
cout << "Result = " << n1 + n2 ;
break;
case '-':
cout << "Result = " << n1 - n2 ;
break;
case '*':
cout << "Result = " << n1 * n2 ;
break;
case '/':
cout << "Result = " << n1 / n2;
break;
}
return 0;
}