Answers for "rust BMI"

0

rust BMI

fn bmi(weight: u32, height: f32) -> &'static str {
    let index = weight as f32 / height.powi(2);
    match index {
        index if index <= 18.5 => "Underweight",
        index if index <= 25.0 => "Normal",
        index if index <= 30.0 => "Overweight",
        _ => "Obese"
    }
}
Posted by: Guest on March-12-2021

Browse Popular Code Answers by Language