Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,990 questions

51,935 answers

573 users

How create BMI calculator and check whether the weight is normal or overweight or underweight 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 << "\n";
    
    if (bmi < 15)  {  
        std::cout << "Starvation"; 
    }  
    else if (bmi >= 15.1 && bmi <= 17.5) {  
        std::cout << "Anorexic";  
    }  
    else if (bmi >= 17.6 && bmi <= 18.5) {  
        std::cout << "Underweight";
    }  
    else if (bmi >= 18.6 && bmi <= 24.9) {  
        std::cout << "Ideal";
    }  
    else if (bmi >= 25 && bmi <= 25.9) {  
        std::cout << "Light Overweight";
    } 
    else if (bmi >= 26 && bmi <= 29.9) {  
        std::cout << "Overweight";
    }   
    else if (bmi >= 30 && bmi <= 30.9) {  
        std::cout << "Obese";  
    }  
    else if (bmi >= 40) {  
        std::cout << "Morbidly Obese";
    }  
}



/*
run:

26.2985
Overweight

*/

 



answered Jul 13, 2020 by avibootz
...