Sum a std::array
easyQuestion 528Write a function int sumArray(const array<int, 5>& a) that returns the sum of all five elements. Use a range-based for loop to visit each element.
The test calls your function and prints the returned value on its own line. For {1, 2, 3, 4, 5} it prints the output shown in Expected Output.
Do NOT write a main function.
Expected output
15 20
= newline. The output ends with a newline, so print one after the last line.
Hints4 available
Sign in to use hintsTopics
STL Containersstd::array
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Shift+Alt+F to format · Ctrl+Space to expand shortcuts (cout, fori)
Your output
Run your code to see the output here...
Test cases
Run your code to see test case results.