How to calculate the body mass index (BMI) in C++

1 Answer

0 votes
#include <iostream>

float BMI(float weight, float height) {
    return weight / (height * height);  
}

int main() {
    float weight = 100.00; // kg
    float height = 1.95; // meter
    float bmi = BMI(weight, height);
    
    std::cout << bmi;
}



/*
run:

26.2985

*/

 



answered Jul 13, 2020 by avibootz
edited Jul 13, 2020 by avibootz
...