C语言 学生成绩求和

编写程序实现录入班级学员c语言成绩的功能,要求录入四个学员成绩,并求出总成绩,和平均成绩,平均成绩(精确到小数点后两位).

#include <stdio.h>void main()
{
float a , b , c , d,sum,average;
printf("please input four numbers!\n");
scanf("%f %f %f %f",&a,&b,&c,&d);
sum=a+b+c+d; average=sum/4; printf("the sum is %6.2f\n the average is %6.2f",sum,average);
}
温馨提示:答案为网友推荐,仅供参考
第1个回答  2013-05-05
#include <stdio.h>

int main(int argc, char *argv[])
{
int i;
float score[4], all_score = 0, ave_score = 0;
printf("请输出4个学生的成绩:\n");
for(i=0; i<4; i++)
scanf("%f", &score[i];
for(i=0; i<4; i++)
all_score += score[i];
ave_score all_score/4;
printf("总成绩:%.2f\n平均成绩:%.2f\n", all_score, ave_score);

return 0;
}
相似回答