Exerpad
🔥 0
0 XP
Exercise 4 · Chapter: VectorsRequired+50 XP

Find Biggest

Find and print the largest number in this vector: vec![4, 9, 2, 7, 5].

Expected output:

9

Hints:

  • Start by setting max to the first item: let mut max = numbers[0];
  • Loop through the vector with for &n in &numbers
  • If n > max, update max to n
  • Print max at the end
rust
fn main() {
}
Output
Run your code to see the output here.