← Back to STL Containers
Question 532
Largest in a std::array
Largest in a std::array
Write a function int maxOf(const array<int, 6>& a) that returns the largest of the six values. It must work when every value is negative.
The test prints the returned value on its own line. For {3, 42, 7, 1, 9, 15} it prints the output shown in Expected Output.
Do NOT write a main function.Expected Output:
42 -1
= newline. The output ends with a newline — 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.