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;
}
如有帮助,请点击我的回答下方的【采纳该答案】按钮帮忙采纳下,谢谢!