Integer Division and Type Casting
The integer variables sum and count store the sum of all scores and the number of games played, respectively. Both variables have been initialized with positive values. Which of the following statements correctly calculates the average score and assigns the result to a double variable named average?
A
double average = sum / count;
B
double average = double (sum / count);
C
double average = (double) (sum / count);
D
double average = (double) sum / count;
Question Leaderboard
| Rank | |||||
|---|---|---|---|---|---|
| #1 | shelter2002004 | 1 | 1 | 0m 32s | 68 |
| #2 | parth.taur227 | 1 | 1 | 0m 43s | 57 |
| #3 | y.seong2027 | 1 | 2 | 0m 46s | 44 |
| #4 | patrickmeijer009 | 1 | 2 | 0m 46s | 44 |
| #5 | jaimonjosh | 0 | 1 | 0m 46s | -56 |
| #6 | thamminenigamya | 1 | 1 | 3m 45s | -125 |
| #7 | lsj08030922 | 1 | 1 | 4m 06s | -146 |
| #8 | bommasam000 | 1 | 2 | 5m 02s | -212 |
Items per page:
10
1 – 8 of 8
APFIVE