Find the Smallest Element
easyQuestion 99An array called nums has already been created for you with the values {30, 10, 50, 20, 40}. Notice the values are not in order.
A variable called min has been initialized to nums[0] (the first element). Your task is to loop through the rest of the array and update min whenever you find a value that is smaller than the current min.
Inside the loop, compare each element to min. If nums[i] is less than min, update min to that value.
After the loop, print the result in the exact format shown in Expected Output.
Expected output
Smallest: 10= newline. No newline after the last line.
Hints2 available
Sign in to use hintsTopics
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.