CJCoding With Joseph
15free / daySign inCreate account

Smallest Element in an Array

Finding the smallest value works just like finding the largest, but you flip the comparison. Assume the first element is the smallest so far, then scan the rest of the array and keep any value that is smaller than your current minimum. When the loop ends you have the smallest number. Print 'Min: ' followed by that value.

Expected Output:

Min: 2

= 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.