Integer Division in Array Calculation
What is printed to the console when the following code is executed?
public class Main {
public static void main(String[] args) {
int[] scores = {88, 92, 76, 81};
int total = 0;
for (int i = 0; i < scores.length; i++) {
total += scores[i];
}
double average = total / scores.length;
System.out.println(average);
}
}
A
337
B
84
C
84.0
D
84.25
Question Leaderboard
| Rank | |||||
|---|---|---|---|---|---|
| #1 | suhanakochhar006 | 0 | 1 | 0m 00s | 0 |
| #2 | singhris000 | 1 | 2 | 1m 32s | -2 |
| #3 | geethasailaja | 0 | 1 | 0m 15s | -25 |
| #4 | midnightasdark | 2 | 2 | 4m 26s | -66 |
| #5 | namansoin000 | 0 | 1 | 0m 56s | -66 |
| #6 | y.seong2027 | 1 | 2 | 2m 42s | -72 |
| #7 | suhanakochhar006 | 0 | 2 | 8m 47s | -547 |
| #8 | bommasam000 | 3 | 8 | 1h 45m | -6,103 |
Items per page:
10
1 – 8 of 8
APFIVE