calling functions HELP(need to eliminate duplication)

Okay so what im trying to accomplish here is that i want to make it so
a person inputs 2 numbers.

Then i want to add those two numbers,subtract,multiply and divide them as well.

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
  #include <iostream>

using namespace std;

void Start_Program();
void Sub_Program();
void Multi_program();
void Div_Program();
void Add_Program();

int main()
{
    Start_Program();

    return 0;
}
void Start_Program(){
    int number1=0;
    int number2=0;

    Add_Program();
    Sub_Program();
    Multi_program();
    Div_Program();

    cin >>number1;
    cin >>number2;
}
void Add_Program(){
    int number1=0;
    int number2=0;

cout << "This program will add 2 whole numbers and calculate them \n";
cout <<number1 + number2 << endl;

}
void Sub_Program(){
    int number1=0;
    int number2=0;

cout << "This program will subtract numbers and calculate them \n";
cout <<number1 - number2 <<endl;

}
void Multi_program(){
    int number1=0;
    int number2=0;

cout << "This program will multiply and calculate them \n";
cout <<number1 * number2 <<endl;
}
void Div_Program(){
    int number1=0;
    int number2=0;

cout << "This program will divide numbers and calculate them \n";

cout <<number1 / number2 <<endl;
}
i want to make it so a person inputs 2 numbers. Then i want to add ...

vs.
1
2
3
4
5
Add_Program();
// ...

cin >>number1;
cin >>number2;

You say that you want to input first and calculate later, but your code calculates first and takes input later.

Check how you can pass information into functions with parameters: http://www.cplusplus.com/doc/tutorial/functions/
Topic archived. No new replies allowed.