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

Function average

Examples/Modules/Chapter 10/Ex10_04.cpp:25–31  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

23
24template <typename T, size_t N>
25T average(const T(&array)[N])
26{
27 T sum{}; // Accumulate total in here
28 for (size_t i{}; i < N; ++i)
29 sum += array[i]; // Sum array elements
30 return sum / N; // Return average
31}

Callers 1

mainFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected