Spelling A
7-2 Find the mean value of an integer (20 points)
This question requires writing a program to calculate the sum and average of 4 integers. The question guarantees that the input and output are within the integer range.
Input format:
Input 4 integers in one line, separated by spaces.
Output format:
output the sum and the average value in the order of the format "Sum = and; Average = average value" in one line, where the average value is accurate to one decimal place.
Input example:
1 2 3 4
Output example:
Sum = 10; Average = 2.5
When the format error is frequently prompted, you can directly copy and paste the format given in the title and modify it.
include<stdio.h>
int main()
{
int a,b,c,d,Sum;
float Average; // 新手需要注意的是Averge是 float 而非int.
scanf("%d %d %d %d",&a,&b,&c,&d);
Sum = a + b + c + d;
Average = Sum / 4.0;
printf("Sum = %d; Average = %.1lf",Sum,Average);
return 0;
}