Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int x;
- int y;
- int d;
- string op;
- int answer;
- int calc (string op, int x, int y) {
- if (op == "Mult" || "mult" || "MULT"){
- d = x * y;
- }else if (op == "Div" || "div" || "DIV"){
- d = x / y;
- }else if (op == "Add" || "add" || "ADD"){
- d = x + y;
- }else if (op == "Sub" || "sub" || "SUB"){
- d = x - y;
- }else{
- cout << "Error";
- }
- return d;
- }
- void printanswer() {
- answer = calc(op, x, y);
- cout << "Answer:" << answer;
- cout << "Parameters: " << op << x << y;
- }
- int main() {
- cout << "What Operation? (Mult, Div, Sub, Add)";
- cin >> op;
- cout << "First Number?";
- cin >> x;
- cout << "Second Number?";
- cin >> y;
- printanswer();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement