How to find the Minimum of Three Numbers in Rust - Step by Step Examples
How to find the Minimum of Three Numbers in Rust ?
Answer
To find the minimum of three numbers in Rust, you can use the `min` function from the std library.
✐ Examples
1 Find Minimum of Three Numbers
In this example,
- We declare three variables
a
,b
, andc
with the numbers to compare. - We use the `min` function to compare the numbers and get the minimum.
Rust Program
fn main() {
let a = 5;
let b = 8;
let c = 3;
let min = a.min(b).min(c);
println!("Minimum of three numbers is: {}", min);
}
Output
Minimum of three numbers is: 3
Summary
In this tutorial, we learned How to find the Minimum of Three Numbers in Rust language with well detailed examples.