[PTA] 7-9 integer seeking mean (10 minutes)

This problem requires programming, and four integer calculated average value. Title ensure that the input and the output are within the range of integers.

Input format:
input are four integer in a row, separated by a space therebetween.

Output formats:
in the format line "Sum = and; Average = Average" and sequentially outputs the average value, wherein an average value of decimal place.

Input Sample:
1 2 3 4

Output Sample:
the Sum = 10; Average = 2.5

#include <stdio.h>
int main()
{
    int a,b,c,d;
    int sum;
    double average;
    scanf("%d %d %d %d",&a,&b,&c,&d);
    sum=a+b+c+d;
    average=sum/4.0;
    printf("Sum = %d; Average = %.1f",sum,average);

return 0;
}
Published 48 original articles · won praise 0 · Views 334

Guess you like

Origin blog.csdn.net/weixin_46399138/article/details/105331621