Exercise · Operators · lesson 9 of 9
Exercise: average of three
Write a function func average(a, b, c int) float64 that returns the arithmetic mean of three integers, fractional part included.
average(1, 2, 3)→2average(1, 2, 2)→1.6666666666666667average(-1, -2, -4)→-2.3333333333333335
Constraints: the numbers are from -1000 to 1000 and may be negative; the result is compared with a tolerance of 1e-9.
Do not add extra imports unless the task says so explicitly.
Subscribe to take the course
The course is free. Sign in with Telegram and subscribe to the channel to open every lesson.