Would like to ask the average has been=0,
#include
Float business (float sum [10]);
Void main ()
{
Float score [10], the result;
Printf (" please enter the number 10: \ n ");
The scanf (" % d ", & amp; Score);
Result=average (score);
Printf (" business=% f ", result);
}
Float business (float sum [10])
{
Float resule=0, I;
for(i=0; i<10; I++)
{
Resule +=sum [10].
}
Resule/=10;
Return the resule;
}
CodePudding user response:
The building Lord did not make clear the scanf usage, if you want to input 10 value to use a loop to input, this will only get a value, the array a [] in the scanf don't add & amp;Is address values, then the function part, resule +=sum [10]. This is not a 10, but, every time you add is an array of all 9, is zero. So you output is 0
CodePudding user response:
#includeFloat business (float sum [10]);
Void main ()
{
Float score [10], the result;
Printf (" please enter the number 10: \ n ");
for (int i=0; I & lt; 10; I++)
{
The scanf (" % f ", & amp; Score [I]);
}
Result=average (score);
Printf (" business=% f ", result);
}
Float business (float sum [10])
{
Float resule=0;
for (int i=0; I & lt; 10; I++)
{
Resule +=sum [I];
}
Resule/=10;
Return the resule;
}
The building Lord help you to change good, not
the upstairs.
CodePudding user response:
Ok thank you very much,CodePudding user response: