aboutsummaryrefslogtreecommitdiffstats
path: root/ee1301/wk2/lab2/calc.cpp
blob: f2e0e87e729b3ab8e98346225c12874c3a9daf3d (plain) (blame)
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
#include <iostream>
using namespace std;

int main () {
  int a,b;
  char op;
  cout << "Enter an equation: ";
  cin >> a >> op >> b;
  cout << a << op << b << " = ";
  
   if (op=='+'){
     cout << a + b;
   }

   if (op=='-'){
     cout << a - b;
   }

   if (op=='*'){
     cout << a * b;
   }

   if (op=='/'){
     cout << a / b;
   }

   cout << endl;
 }