问答题

编写函数fun,其功能是:计算n门课程的平均分,结果作为函数值返回。
例如,若有5门课程的成绩是:90.5,72,80,61.5,55,则函数的值为71.80。
注意 :部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入你编写的若干语句。
试题程序:
#include<stdio.h>
float fun(float *a,int n)
{
}
void main()
{
float score[30]={90.5,72,80,61.5,5,5},aver;
aver*fun(score,5);
printf("\nAverage score is:%5.2f\n", aver);
}

【参考答案】

float fun (float *a , int n)
{
int i;
float a......

(↓↓↓ 点击下方‘点击查看答案’看完整答案 ↓↓↓)
热门 试题

填空题