c语言有人知道怎么做嘛

img


Please write a program to calculate and display the average of single floating-point numbers :1, 1.1, 1.2 , ... , 2.0
写一个程序计算下列数字的均值1, 1.1, 1.2 , ... , 2.0

你题目的解答代码如下:

#include <stdio.h>
int main()
{
    int n=0;
    double sum=0,f;
    for (f = 1.0; f <= 2.0; f+=0.1)
    {
        sum += f;
        n++;
    }
    printf("均值= %.2lf", sum/n);
    return 0;
}

img

如有帮助,请点击我的回答下方的【采纳该答案】按钮帮忙采纳下,谢谢!

img

您好,我是有问必答小助手,您的问题已经有小伙伴帮您解答,感谢您对有问必答的支持与关注!
PS:问答VIP年卡 【限时加赠:IT技术图书免费领】,了解详情>>> https://vip.csdn.net/askvip?utm_source=1146287632