Programming Challenge Chapter 4 – Q #5 Body Mass Index – Tony Gaddis – Starting Out With C++

Programming Challenge Chapter 4 – Q #5 Body Mass Index  – Tony Gaddis – Starting Out With C++

Programming Challenge Chapter 4 – Q #5 Body Mass Index  – Tony Gaddis – Starting Out With C++


Problem: -

Body Mass Index
Write a program that calculates and displays a person's body mass index (BMI). The BMI is often used to determine whether a person with a sedentary lifestyle is overweight or underweight for his or her height. A person's BMI is calculated with the following formula:
                                                  BMI = weight × 703 / height*height
where weight is measured in pounds and height is measured in inches. The program should display a message indicating whether the person has optimal weight, is underweight, or is overweight. A sedentary person's weight is considered to be optimal if his or her BMI is between 18.5 and 25. If the BMI is less than 18.5, the person is considered to be underweight. If the BMI value is greater than 25, the person is considered to be overweight.

Solution: -

#include<iostream>
using namespace std;
int main()
{
//Declare Variables
int weight, height;
float bmi;

    //Take Input From the User
cout << "Enter Your Weight in Pounds: ";
cin >> weight;
cout << "Enter Your Height in Inches: ";
cin >> height;
    
    //Calculate BMI by Using Formula
bmi = (weight * 703) / (height * height);
    
    //Use if else if condition For Checking
if (bmi < 18.5)
cout << "Your weight is Underweight";
else if (bmi > 25)
cout << "Your weight is Overweight";
else
cout << "Your weight is Optimal";

return 0;
}

This is the solution of this question




OUTPUT OF THIS QUESTION



Explanation of this Solution

Solution Explain With Comments in Solution.


Also, I attach CPP file of this problem. You can download this file

Click Here to Download This File

Post a Comment

0 Comments