func2 takes 'c'
by value, meaning that c is a COPY of the variable you pass in, and is not the variable itself.
If you change 'c' in func2, it will not change 'num3' in main because it's a different variable.
You probably intended to pass it as a reference:
|
void func2(int a, int b, double& c) // <- note the & symbol
|
By passing it as a reference, 'c' is no longer a copy, but actually
is the variable being passed in.
But a better approach would be to return the number, rather than pass by value:
1 2 3 4 5 6 7 8 9 10 11 12 13
|
double func2(int a, int b) // <- only take input as params, return the output
{
if (a != 0 && b != 0)
{
if (a >=b)
return pow(a, b); // <- return output, rather than assign it to 'c'
else
return pow(b, a);
}
...
num3 = func2( num1, num2 ); // <- call the function like this, assign the returned value to num3
|
Lastly... your names are terrible. 'func1', 'func2', 'num1', 'a', etc are not at all descriptive. You should pick names which identify the functions/variables by purpose. It will go a long way in improving code clarity.