Heya folks. I'm trying to write a BMI calculator, but I'm missing something.
Splint tells me I have a parse error before the scanf, but I'm not seeing it. Also, I'm struggling to get the BMI to print (I'm pretty sure the two are related). It worked (before I put in the ifs), I added the ifs, now it's broken and I can't get it fixed. Certainly it's something simple, but I'm just not seeing it.
Specifically, it enters the while loop with no issue (i.e. when invalid data is entered), but never seems to hit the ifs.
Thanks in advance.
#include <stdio.h>
int
main()
{
float height, weight;
printf("Enter your height in inches and weight in pounds: \n");
scanf("%f%f", &height, &weight);
float bmi = (weight/(height*height));
while(height <= 0 || weight <= 0)
{
printf("That's not valid data...\n");
printf("Enter your height and weight: \n");
scanf("%f%f", &height, &weight);
}
if (bmi < 18.5)
printf("Your BMI is %.1f. You're underweight.\n", bmi);
else if (bmi >= 18.5 && bmi <= 24.9)
printf("Your BMI is %.1f. You're pretty normal.\n", bmi);
else if (bmi >= 25.0 && bmi <= 29.9)
printf("Your BMI is %.1f. You're slightly overweight.\n", bmi);
else
printf("Your BMI is %.1f. You're obese.\n", bmi);}