Quite a few things are noteworthy:
1) Functions cannot be defined within another function. However, functions can be declared inside a function, but common (and preferred) practice is to declare functions outside a function.
2) Inside the definition of "
smallest_value( )", "
else" statements cannot test conditions. The way conditionals are formed in C++ is the following:
1 2 3 4 5 6 7 8 9 10 11 12
|
if( Something )
{
}
else if( Something_Else... )
{
}
else
{
// None of the above...
}
|
Because you have two adjacent "
else" statements, the compiler will complain that the second "
else" does not have a corresponding "
if".
3) In "
average( )", "
sum" cannot hold single-/double-precision values, so, on line 29, the values of "
x", "
y" and "
z" are rounded to the lowest whole number so that "
sum" can hold the value of the computation. It would be better to be consistent and declare "
sum" as a "
double".
4) On lines 33 and 34, you're trying to call "
smallest_value( )" and "
average( )", respectively, but the compiler thinks otherwise. To invoke, or call, a function, you need to do the following:
1 2 3 4
|
int main( )
{
FunctionName( Arguments );
}
|
Wazzak