MCPcopy Create free account
hub / github.com/Apress/beginning-cpp20 / average10

Function average10

Examples/Modules/Chapter 08/Ex8_09A.cpp:16–22  ·  view source on GitHub ↗

Function to compute an average

Source from the content-addressed store, hash-verified

14
15// Function to compute an average
16double 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}

Callers 1

mainFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected