printf("Enter a weight (kg) : ");
scanf_s("%d", &weight);
printf("Enter a height (m) : ");
scanf_s("%d", &height);
BMI = weight / (height * height);
if (BMI < 16)
printf("You are seriously underweight. Your BMI is %.2f\n", BMI);
if (BMI > 16 && BMI < 18)
printf("You are underweight. Your BMI is %.2f\n", BMI);
if (BMI > 18 && BMI < 24)
printf("You are normal weight. Your BMI is %.2f\n", BMI);
if (BMI > 24 && BMI < 29)
printf("You are overweight. Your BMI is %.2f\n", BMI);
if (BMI > 29 && BMI < 35)
printf("You are seriously overweight. Your BMI is %.2f\n", BMI);
if (BMI > 35)
printf("You are gravely overweight. Your BMI is %.2f\n", BMI);
return 0;
}
if someone could check this over and let me know the issue. Thank you so much
In c/c++, if the two numbers being divided are both int, then the result is int.
So 7 / 2 is 3 and not 3.5 as perhaps expected. But 7 / 2.0 (or 7.0 / 2 or 7.0 / 2.0) is 3.5 as at least one of the numbers is floating point - so the result is floating point.