-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprogram5.cpp
More file actions
31 lines (27 loc) · 788 Bytes
/
program5.cpp
File metadata and controls
31 lines (27 loc) · 788 Bytes
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
#include <iostream>
using namespace std;
int main()
{
cout <<"Enter an operator(+,-,*,/): ";
char op;
cin >> op;
cout << "Enter two numbers: ";
double num1, num2;
cin >> num1 >> num2;
switch (op)
{
case '+':
cout << "Adding " << num1 << " and " << num2 << " gives " << num1 + num2 << endl;
break;
case '-':
cout << "Subtracting " << num1 << " and " << num2 << " gives " << num1 - num2 << endl;
break;
case '*':
cout << "Multiplying " << num1 << " and " << num2 << " gives " << num1 * num2 << endl;
break;
default:
cout << "Dividing " << num1 << " and " << num2 << " gives " << num1 / num2 << endl;
break;
}
return 0;
}