- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathifsum.cpp
More file actions
Latest commit
27 lines (26 loc) · 486 Bytes
/
Copy pathifsum.cpp
File metadata and controls
27 lines (26 loc) · 486 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
#include<iostream>
usingnamespacestd;
intmain()
{
char op;
int a,b,sum,diff;
cout << "Enter an operator:";
cin >> op;
cout << "Enter two integers:";
cin >> a >> b;
if (op == '+')
{
sum = a + b;
cout << a << op << b << "=" << sum << '\n';
}
elseif (op == '-')
{
diff = a - b;
cout << a << op << b << "=" << diff << '\n';
}
else
{
cout << "unrecongised operator";
}
return0;
}