Answer:
The Answer for the given question is
First is return(average ) statement is not used in the last line in function average .
second not included the parenthesis in adding the value1 + value2 + value3 so include (value1 + value2 + value3 )
Third is not type casting the value so type cast the value by modify that statement
average = float(value1 + value2 + value3 )/ 3;
Step-by-step explanation:
In the given code the return type is float that means function should return float value.So adding the statement in the last line return(average ) here all the parameters are of int type but "average" is float type and when an int is divided by int, it will return int value. So we have to type cast either denominator or numerator.
average = float(value1 + value2 + value3 )/ 3;
To define any function definition it must follow the proper syntax of function definition
The syntax is :
Returntype functionname(datatype parameter1,datatype parameter 2)
{
//statement
}
For example
int mux(int a,int b)
{
int c;
c=a*b;
return(c);
}
In this the returntype is integer thats why it return integer value c. If return type is void it will not return any value .
So the correct code is
float average(int value1, int value2, int value3)
{
float average;
average = float(value1 + value2 + value3 )/ 3;
return(average);
}