Body Mass Index (BMI) is a measure of health based on height and weight. You can calculate your BMI by taking your weight in kilograms and dividing it by the square of your height in meters
Body Mass Index (BMI) is a measure of health based on height and weight. You can calculate
your BMI by taking your weight in kilograms and dividing it by the square of your height in
meters. The interpretation of BMI for people 20 years or older is as follows:
BMI Interpretation
BMI < 18.5 Underweight
18.5 <= BMI < 25.0 Normal
25.0 <= BMI < 30.0 Overweight
30.0 <= BMI Obese
#include<iostream>
using namespace std;
int main()
{
//weight in kilograms
float kilograms;
//height in meters
float meters;
//enter the values
cout<<" enter your weight in kilograms ";cin>>kilograms;
cout<<" enter your height in meters ";cin>>meters;
//calculate BMI
//formula: weight in kilo / (height in meter)*(height in meter)
float BMI = kilograms / (meters*meters);
cout<<" your BMI is "<<BMI<<endl;
if(BMI<18.5)
{
//BMI < 18.5 Underweight
cout<<" you are under weight";
}
else if(18.5<= BMI && BMI<25)
{
//18.5 <= BMI < 25.0 Normal
cout<<" you are normal";
}
else if(25<= BMI && BMI<30)
{
//25.0 <= BMI < 30.0 Overweight
cout<<" you are Overweight";
}
else
{
//30.0 <= BMI Obese
cout<<" you are Obese";
}
return 0;
}
output:-
enter your weight in kilograms 50
enter your height in meters 1.72
your BMI is 16.901
you are under weight
-------------------------------------------
enter your weight in kilograms 60
enter your height in meters 1.72
your BMI is 20.2812
you are normal
------------------------------------------
enter your weight in kilograms 80
enter your height in meters 1.72
your BMI is 27.0416
you are Overweight
-------------------------------------------
enter your weight in kilograms 90
enter your height in meters 1.72
your BMI is 30.4218
you are Obese
--------------------------------------------
Comments
Post a Comment
Any doubt about programming or questions