Average of Three
Completed
Read three integers and print their average with 2 decimals.
Input
Three integers.
Output
The average.
Example
Input
1 2 4
Output
2.33
Editor
C
Hints
Divide by 3.0, not 3, to get a decimal result.
Solution explanation
One double operand is enough to make the division a floating-point division.
Show solution
#include <stdio.h>
int main() {
int a, b, c;
scanf("%d %d %d", &a, &b, &c);
printf("%.2f\n", (a + b + c) / 3.0);
return 0;
}