### Confused with this program.

I'm getting some run time errors with this program. This is a practice program I'm working on. Problem: (Make your calculator program perform computations in a separate function for each type of computation)

Basically, after the user enters the two numbers he wants to be used it asks for what type of operation the user wants to use, and when you enter the operation and hit enter the program ends. I'm not sure where in my program there is a problem and I'm completely stumped. Any help would be greatly appreciated.

 ``123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263`` ``````#include #include using namespace std; //------Function prototypes---------| void add ( int numb1, int numb2); void subtract (int numb1, int numb2); void multiply (int numb1, int numb); void divide (int numb1, int numb2); int main() { int numb1; int numb2; string operation; cout << "Enter the first number and then the second number" << "\n"; cin >> numb1; cin >> numb2; cout << "Select the type of operation you want to do: add, subtract, multiply, or divide" << "\n"; cin >> operation; if(operation == "add") { void add (int numb1, int numb2); } else if(operation == "subtract") { void subtract (int numb1, int numb2); } else if (operation == "multiply") { void multiply (int numb1, int numb2); } else if (operation == "divide") { void divide (int numb1, int numb2); } return 0; } //------------------------Arithmetic functions----------------------| void add (int numb1, int numb2) { cout << numb1 << "+" << numb2 << "=" << numb1 + numb2; } void subtract (int numb1, int numb2) { cout << numb1 << "-" << numb2 << "=" << numb1 - numb2; } void multiply (int numb1, int numb2) { cout << numb1 << "*" << numb2 << "=" << numb1 * numb2; } void divide (int numb1, int numb2) { cout << numb1 << "/" << numb2 << "=" << numb1 / numb2; }``````
Please see the forum sticky Console closing down.

Also you might want to check for division by zero.
Go look up how to call functions; currently you are not calling them correctly.
Use a pointer reference for the parameters in your function.
Topic archived. No new replies allowed.