CJCoding With Joseph
15free / daySign inCreate account

Find the Largest Element

An array called nums has already been created for you with the values {10, 40, 20, 50, 30}. Notice the values are not in order.

A variable called max has been initialized to nums[0] (the first element). Your task is to loop through the rest of the array and update max whenever you find a value that is larger than the current max.

Inside the loop, compare each element to max. If nums[i] is greater than max, update max to that value.

After the loop, print the result in the exact format shown in Expected Output.

Expected Output:

Largest: 50

= newline. No newline after the last line.

Hints2 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 (cout, fori)

Your Output

Run your code to see the output here...

Test Cases

Run your code to see test case results.