The Body Mass Index (BMI) is a quick way to assess your body size simply with your weight and height, regardless of your gender. Quickly calculate your BMI and find out which category you fall into.
Body mass index (BMI) is a measure of body fat based on height and weight that applies to adult men and women. It is calculated by dividing an individual’s weight in kilograms by their height in meters squared. The resulting number is used to determine if a person is underweight, normal weight, overweight, or obese.
Here is the BMI classification system used by the World Health Organization (WHO):
- BMI less than 18.5: Underweight
- BMI 18.5 to 24.9: Normal weight
- BMI 25.0 to 29.9: Overweight
- BMI 30.0 or greater: Obese
It is important to note that BMI is not a diagnostic tool and should not be used as the sole means of determining a person’s health status. It is simply one factor to consider along with other measures such as body composition, waist circumference, and medical history.
In this program we will calculate BMI. Body mass index (BMI) is a measure of body fat based on height and weight that applies to adult men and women.
C++ Program to Calculate Your Body Mass Index
Write a program that computes the body mass index (bmi) of an individual in C++
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | #include <iostream> #include <cmath> using namespace std; int main() { // Declare variables for weight and height double weight_pounds, height_inches; // Prompt the user to enter their weight in pounds cout << "Enter your weight in pounds: "; cin >> weight_pounds; // Prompt the user to enter their height in inches cout << "Enter your height in inches: "; cin >> height_inches; // Calculate the BMI by dividing the weight in pounds by the height in inches squared, and then multiplying by 703 double bmi = (weight_pounds / (pow(height_inches, 2))) * 703; // Print the BMI to the console cout << "Your BMI is: " << bmi << endl; return 0; } |
Output:
1 2 3 4 5 | Enter your weight in pounds: 50 Enter your height in inches: 40 Your BMI is: 21.9688 |
Alternative: Here is an example BMI calculator program in C++ that uses pounds as the unit of measurement and outputs a message indicating whether the user is normal weight, overweight, or obese:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | #include <iostream> #include <cmath> using namespace std; int main() { // Declare variables for weight and height double weight_pounds, height_inches; // Prompt the user to enter their weight in pounds cout << "Enter your weight in pounds: "; cin >> weight_pounds; // Prompt the user to enter their height in inches cout << "Enter your height in inches: "; cin >> height_inches; // Calculate the BMI by dividing the weight in pounds by the height in inches squared, and then multiplying by 703 double bmi = (weight_pounds / (pow(height_inches, 2))) * 703; // Print a message indicating whether the user is normal weight, overweight, or obese if (bmi < 18.5) { cout << "You are underweight." << endl; } else if (bmi >= 18.5 && bmi < 25.0) { cout << "You have a normal weight." << endl; } else if (bmi >= 25.0 && bmi < 30.0) { cout << "You are overweight." << endl; } else { cout << "You are obese." << endl; } return 0; } |
Output:
1 2 3 4 5 | Enter your weight in pounds: 161 Enter your height in inches: 67 You are overweight. |
This program is similar to the previous example, but it includes additional code to print a message indicating whether the user is normal weight, overweight, or obese based on their BMI. The program uses an if-else statement to check the value of the BMI and output the appropriate message.
I hope this helps!
You May Also Like:
[…] BMI Calculator Program in C++ […]
[…] BMI Calculator Program in C++ […]