# define N 12
Float business (float cost [], int I);
Int main ()
{
Float cost [N], aver;
Aver=Average (cost, N);
Printf (" business cost is % f \ n ", aver);
return 0;
}
Float business (float cost [], int I)
{
Float aver, sum;
for(i=0; i
The scanf (" % f ", & amp; Cost [I]);
The sum +=cost [I];
}
Aver=sum/N.
Return aver.
}
CodePudding user response:
Float business (float cost [], int )//here I pass an I{
Float aver, sum;
for(i=0; i
{
The scanf (" % f ", & amp; Cost [I]);
The sum +=cost [I];
}
Aver=sum/N.
Return aver.
}
You can pass the function's parameters need not I, to n
Inside the function body used twice the N with N, this way is to use the
Usually, the logic of the program is not designed
The program will enter a first n
Then enter n number in the array inside
Then call this function to calculate the average
CodePudding user response:
I hope it can help you: https://blog.csdn.net/it_xiangqiang/category_10581430.htmlI hope it can help you: https://blog.csdn.net/it_xiangqiang/category_10768339.html