topic
This question requires a program to calculate the sum and average of 4 integers. The problem is to ensure that the input and output are within the integer range.
Input format:
The input gives 4 integers on one line, separated by spaces.
Output format:
The sum and average values are output in the order of the format "Sum = and; Average = average value" in a line, where the average value is accurate to one decimal place.
Sample input:
1 2 3 4
Sample output:
Sum = 10; Average = 2.5
Code
#include<stdio.h>
int main(){
int a,b,c,d,interge,point;
scanf("%d %d %d %d",&a,&b,&c,&d);
interge=(a+b+c+d)*10/4;
point=interge%10;
interge/=10;
printf("Sum = %d; Average = %d.%d",a+b+c+d,interge,point);
return 0;
}