CJCoding With Joseph
15free / daySign inCreate account

Largest Value and Its Index

Finding the maximum is useful, but often you also want to know WHERE it is. This exercise combines two things to track: the largest value seen so far, and the index at which it was found. Start both from element 0. As you loop, whenever you find a bigger value, update the max AND record the current index. Finally print a line in the exact form: Max <value> at index <index>.

Expected Output:

Max 89 at index 3

= newline. No newline after the last line.

Hints4 available
Topics:
Arrays
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Shift+Alt+F to format · Ctrl+Space to expand shortcuts (p, fori)

Your Output

Run your code to see the output here...

Test Cases

Run your code to see test case results.