读取成绩,计算平均考试成绩

#include stdio.hint main(){int numTest;float stTest, avg, total = 0.0;for (numTest = 0; numTest 25; numTest++)

编程学习网为您整理以下代码实例,主要实现:读取成绩,计算平均考试成绩,希望可以帮到各位朋友。

#include <stdio.h>

int main()
{
    int numTest;
    float stTest, avg, total = 0.0;

    for (numTest = 0; numTest < 25; numTest++)
    {
        printf("\nWhat is the next student's test score? ");
        scanf(" %f", &stTest);

        if (stTest < 0.0)
        {
            break;
        }

        total += stTest;
    }

    avg = total / numTest;

    printf("\nThe average is %.1f%%.\n", avg);

    return 0;
}
本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐