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

Function average10

Exercises/NoModules/Chapter 09/Soln9_06.cpp:17–23  ·  view source on GitHub ↗

Function to compute an average

Source from the content-addressed store, hash-verified

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

Callers 1

mainFunction · 0.70

Calls 1

sizeMethod · 0.45

Tested by

no test coverage detected