The code I have has an end goal of calculating BMI based on the inputs of the user. The two inputs are inches and pounds, which are converted to cm and kg(metric). The BMI is calculated by (mass in kg)/(height in m)^2. Everything works and BMI is calculated perfectly, my question is how do I label this final output as BMI so I can add additional if statements based on the BMI value?
I figured out how to get my BMI. And thanks for the suggestion malvoliothegood, was wondering why my ^2 wasnt working at first .
- You can use the cmath library pow function to square a number. Include the cmath library at the top of your code
- Declare a variable to store the BMI at the top of main:
- Here is what your code could look like:
//Evaluating BMI BMI = (WeightPound / 2.20462) / pow(((HeightInch*2.540) / 100), 2); cout << "\nYour calculated BMI rating is: " << BMI <<endl;