/*求C语言编程序,输入4个实数,求这4个数的和及平均值并输出。*/
#include
void main()
{
float a,b,c,d;
float sum=0,avg;
printf("请输入这几个数(逗号隔开):\n");
scanf("%f,%f,%f,%f",&a,&b,&c,&d);
sum=a+b+c+d;
avg=sum/4;
printf("这4个数的和sum=%.2f\n平均数avg=%.2f\n",sum,avg);
}
#include "stdio.h"
int main()
{
double x,sum=0,ave;
int i;
for(i=0;i<4;i++)
{
scanf("%lf",&x);
sum+=x;
}
ave=sum/4;
printf("这4个数的和为%lf,平均值为%lf\n",sum,ave);
}
#include "stdio.h"
#define number 4
int main()
{
double x,sum=0,ave;
int i;
for(i=0;i
scanf("%lf",&x);
sum+=x;
}
ave=sum/4;
printf("这4个数的和为%lf,平均值为%lf\n",sum,ave);
}