Function to compute an average
| 14 | |
| 15 | // Function to compute an average |
| 16 | double average10(const double (&array)[10]) /* Only arrays of length 10 can be passed! */ |
| 17 | { |
| 18 | double sum {}; // Accumulate total in here |
| 19 | for (size_t i {}; i < 10; ++i) |
| 20 | sum += array[i]; // Sum array elements |
| 21 | return sum / 10; // Return average |
| 22 | } |