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

Function average10

Exercises/NoModules/Chapter 09/Soln9_05.cpp:15–21  ·  view source on GitHub ↗

Function to compute an average

Source from the content-addressed store, hash-verified

13
14// Function to compute an average
15double average10(std::span<const double, 10> data)
16{
17 double sum{}; // Accumulate total in here
18 for (double val : data)
19 sum += val; // Sum array elements
20 return sum / data.size(); // Return average
21}

Callers 1

mainFunction · 0.70

Calls 1

sizeMethod · 0.45

Tested by

no test coverage detected