-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcalculator.cpp
More file actions
39 lines (38 loc) · 796 Bytes
/
calculator.cpp
File metadata and controls
39 lines (38 loc) · 796 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
32
33
34
35
36
37
38
39
#include <iostream>
using namespace std;
int main7()
{
int n1= 0, n2= 0, sum= 0, sub= 0, mul = 0;
float div= 0;
char opr;
cout << "Please enter an operation to be performed ";
cin >> n1 >> opr >> n2;
if (opr == '+')
{
sum = n1 + n2;
cout << "The sum of 2 numbers are " << sum << endl;
}
else if (opr == '-')
{
sum = n1 - n2;
cout << "The subtraction of 2 numbers are " << sum << endl;
}
else if (opr == '*')
{
sum = n1 * n2;
cout << "The multiplication of 2 numbers are " << sum << endl;
}
else if (opr == '/')
{
sum = n1 / n2;
cout << "The division of 2 numbers is " << sum << endl;
}
else if (opr == '%')
{
sum = n1 % n2;
cout << "The modulous of 2 numbers are " << sum << endl;
}
else
cout << "Please enter a valid operation" << endl;
return 0;
}