is there a way to references parameters from other functions that are not directly linked

hey im trying to reference parameters that have been declared in a function to use in another and am having trouble , ive made a simple calculator program , in this program i need to reference the the input code from function(Darkness ) in other functions and am struggling to do this , so it wants me to reference the char symbol i have entered into the input function(Darkness) to the Main function to figure out what multiplication it will do , then i need to reference the input1 and input2 from the input function(darkness) to the multiplication functions , i realize i can merge this functions so i dont have to reference them but my course wants me to be able to reference parameters from one function into multiple others

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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
 #include <iostream>


void darkness()
{
	char cMathsym;
	float finput1;
	float finput2;
	std::cout << "please enter the maths symbol you would like to use(Press Enter After)" << std::endl;
	std::cin >> cMathsym;
	std::cout << "you chose to Add Please enter 2 number (Press Enter After Each)" << std::endl;
	std::cin >> finput1;
	std::cin >> finput2;
	
	symb( cMathsym )
	


	

	



}

void symb(char& cMathsym2)
{
	float fAnswer;

	switch (cMathsym2)
	{

	case '+':

		fAnswer = Addition(finput1, finput2);

		break;

	case '-':

		fAnswer = Subtract(finput1, finput2);
		break;

	case 'x':


		fAnswer = Multiply(finput1, finput2);
		break;

	case '/':

		fAnswer = Divide(finput1,finput2);
		break;

	}

	std::cout << "the answer is :: " << fAnswer << std::endl;



}






float Multiply(float finput1, float finput2)
{

	return finput1 * finput2;

}
float Subtract(float finput1, float finput2)
{


	return finput1 - finput2;




}
float Divide(float finput1, float finput2)
{


	return finput1 / finput2;




}
float Addition(float finput1, float finput2)
{


	return finput1 + finput2;



}



int main(int argc, char* argv[])
{
	darkness();





	system("pause");
	return 0;
}
Last edited on
Topic archived. No new replies allowed.