用C语言编写一个程序由键盘输入一个学生的6门课程成绩求该学生的总分、平均分并输出。使用循环结构
#include <stdio.h>
int main()
{
float score, total = 0, average;
int i;
for(i = 1; i <= 6; i++)
{
printf("请输入第%d门课程的成绩:", i);
scanf("%f", &score);
total += score;
}
average = total / 6;
printf("该学生的总分为%.2f,平均分为%.2f\n", total, average);
return 0;
}
原文地址: https://www.cveoy.top/t/topic/fWmV 著作权归作者所有。请勿转载和采集!