Max of Two
Create a function called max that takes two i32 values and returns the larger one. Test it with a few different pairs of numbers.
Expected output:
text
Max of 3 and 7 is 7 Max of 10 and 2 is 10 Max of 5 and 5 is 5
Hints:
- Define with
fn max(a: i32, b: i32) -> i32 - Use an
ifexpression to compareaandb - Remember,
ifcan be used as an expression in Rust:if a >= b { a } else { b }
rust
fn main() {
}