aboutsummaryrefslogtreecommitdiffstats
path: root/ee1301/wk2/lab2/calc.cpp
blob: 9cb2e03bb3941d5303a418acd3059bbd351dd605 (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=='+'){ //Addition
     cout << a + b;
   }

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

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

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

   cout << endl;
 }