DEV Community

Discussion on: Daily Challenge #57 - BMI Calculator

Collapse
lordapple profile image
LordApple • Edited on

This seems to do the job

C++:

    const auto& bmi = [](const float& weight, const float& height){
        const float bmi = weight / (height * height);
        return bmi <= 18.0f ? "Underweight" :
               bmi <= 25.0f ? "Normal" :
               bmi <= 30.0f ? "Overweight" :
               "Obese";
    };