I'm very confused with this program.

I think its not working cause I'm not calling the functions right, but I've changed the function calls in every way I could think of and they aren't working. If I change it to anything but what I have I get build errors. This program is a practice problem I'm working on (Make your calculator program perform computations in a separate function for each type of computation.) When the user inputs the type of operation they want to use it doesn't jump to the function that is assigned to the selected operation. If I'm not calling the functions right, can someone rewrite one of the function calls the right way so I can see? Thanks in advance for any help.

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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#include <iostream>
#include <string>

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;
}
This is not a function call, it's a function declaration:
void add (int numb1, int numb2);

THIS is how a function call looks like:
add(numb1, numb2);
Thank you very much Athar :D
Topic archived. No new replies allowed.