aboutsummaryrefslogtreecommitdiffstats
path: root/ee1301/wk2/lab2/calc.cpp
blob: fbc82ddf58803581a3dc1aaf11df129e493fe580 (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
#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;
 }