计算四个等级的平均值,并进行其他一些基本数学计算。

#include <stdio.h>

int main(){
    int grade1, grade2, grade3, grade4;
    float averageGrade, gradeDelta, percentDiff;

    grade1 = grade3 = 88;
    grade2 = 79;

    printf("What did you get on the fourth test");
    printf("An integer between 0 and 100)?");
    scanf(" %d", &grade4);

    averageGrade = (grade1+grade2+grade3+grade4)/4;
    printf("Your average is %.1f./n", averageGrade);
    gradeDelta = 95 - averageGrade;

    percentDiff = 100 * ((95-averageGrade) / 95);

    printf("Your grade is %.1f points lower than the ", gradeDelta);
    printf("top grade in the class (95)/n");
    printf("You are %.1f percent behind ", percentDiff);
    printf("that grade!/n/n/n");

    return 0;
}

原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/266778.html

(0)
上一篇 2022年6月7日
下一篇 2022年6月7日

相关推荐

发表回复

登录后才能评论