Skip to main content

Practice · 2 of 4

Average without truncation

CHALLENGE
Difficulty: beginner+25 XP

Implement double averageOfFour(int a, int b, int c, int d): the mean of four ints. Beware: a + b + c + d / 4 is wrong twice — precedence AND integer division. Cast the **sum** to double before dividing.

Back to lesson: Practice: Typed storage