CJCoding With Joseph
15free / daySign inCreate account

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
Topics:
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.