how do I name a value that is from two outputs

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 are viewing a single comment. View All
malvoliothegood (432)
  • You can use the cmath library pow function to square a number. Include the cmath library at the top of your code #include <cmath>
  • Declare a variable to store the BMI at the top of main: float BMI;
  • 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;