c语言中求多个整数的和及其平均值
1、
#include <stdio.h>
int main(void)
{
int label;
int sum = 0;
int counts = 0;
do
{
int i;
puts("please input the number i.");
printf("i = "); scanf("%d", &i);
sum = sum + i;
counts = counts + 1;
puts("please chose label 0 to continue or other to exit.");
printf("label = "); scanf("%d", &label);
}
while (label == 0);
printf("sum = %d.\n", sum);
printf("mean = %f.\n", (double)sum / counts);
return 0;
}