#include #include #include int add(int, int); // this is called a prototype // it means that later on in our program there will be a function // called add int subtract(int, int); int multiply(int, int); double divide(double, double); int main() { // main is actually a "function" that returns an integer int num1=0; int num2=0; int answer=0; char choice[20]; double divideanswer=0; // ask the user for two numbers // read them into num1 and num2 cout << "Pick a number: "; cin >> num1; cout << "Pick another number: "; cin >> num2; cout << "What operation would you like to do? "; cin >> choice; if (strcmp(choice,"add") == 0) answer = add(num1, num2); else if (!strcmp(choice, "subtract")) answer = subtract(num1, num2); else if (!strcmp(choice, "multiply")) answer = multiply(num1, num2); else divideanswer=divide(num1, num2) if (strcmp(choice, "divide")) cout << "Your answer is " << answer << endl; else cout << "Your answer is " << divideanswer << endl; return 0; } int add(int x, int y) { cout << "About to add... " << endl; return x + y; } int subtract(int x, int y) { return x - y; } int multiply(int x, int y) { return x * y; } double divide(double x, double y) { if (y == 0) { cout << "Cannot divide by zero." << endl; exit(-1); } return x / y; }