Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
Create free account
hub
/
github.com/Apress/beginning-cpp20
/ average
Function
average
Examples/NoModules/Chapter 10/Ex10_04.cpp:25–31 ·
view source on GitHub ↗
Source
from the content-addressed store, hash-verified
23
24
template <typename T, size_t N>
25
T 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
main
Function · 0.70
Calls
no outgoing calls
Tested by
no test coverage detected