Practice ยท 2 of 5
Average without the truncation trap
average(int a, int b) must return the mean as a double. Beware: (a + b) / 2 with two ints truncates BEFORE the assignment. average(1, 2) must be 1.5, not 1.0.
Difficulty: beginner
Press Submit to check your solution.
Back to lesson: Practice: Practice: Types at Work