title: How do I get BMI correct?
body: <p>Having an issue with my calculation to determine BMI. Please advise me where I am going wrong as the answer always returns as -nan(ind). I'm sure that the problem lies with the calculation itself as I have removed the displayFitnessResults function and simplified the code but I still get the error.</p>
  
  <pre><code>#include&lt;iostream&gt;
  #include &lt;cmath&gt;
  using namespace std;
  
  void getData(float weightP, float heightP)
  {
      cout &lt;&lt; "Enter indivual's wight in kilograms and height in metres: ";
      cin &gt;&gt; weightP &gt;&gt; heightP;
  }
  
  float calcBMI(float weightP, float heightP)
  {
      return weightP / (heightP * heightP);
  }
  
  void displayFitnessResults(float calcBMI)
  {
      if (calcBMI &lt; 18.5)
      {
          cout &lt;&lt; "The individuals BIM index is " &lt;&lt; calcBMI &lt;&lt; " and his/her weight status is underweight";
      }
      else if (calcBMI &gt;= 18.5 &amp;&amp; calcBMI &lt;= 24.9)
      {
          cout &lt;&lt; "The individuals BIM index is " &lt;&lt; calcBMI &lt;&lt; " and his/her weight status is healthy";
      }
      else if (calcBMI &lt;= 25 &amp;&amp; calcBMI &gt;= 29.9)
      {
          cout &lt;&lt; "The individuals BIM index is " &lt;&lt; calcBMI &lt;&lt; " and his/her weight status is overweight";
      }
      else (calcBMI &gt;= 30);
      {
          cout &lt;&lt; "The individuals BIM index is " &lt;&lt; calcBMI &lt;&lt; " and his/her weight status is obese";
      }
  }
  
  
  int main()
  {
      float weight{}, height{}, BMI{};
  
      cout.setf(ios::fixed);
      cout.precision(2);
  
      getData(weight, height);
  
      BMI = calcBMI(weight, height);
  
      displayFitnessResults(BMI);
  
      return 0;
  }
  </code></pre>