我正在尝试编写一个程序,该程序将接受用户输入的体重和身高,然后返回一个 BMI 值并告诉用户他们的体重是否低于/超过或正常。代码编译时没有错误,但是无论我为体重和身高输入什么数字,结果始终是“您的 BMI 为 0 并且您的体重状态超重”。我的代码有问题还是我的数学不正确?
#include <stdio.h>
int main()
{
double wt_lb, ht_in, bmi, ht_ft;
printf("Please enter your weight in whole pounds: ");
scanf("%lf", &wt_lb);
printf("Please enter your height in whole inches: ");
scanf("%lf", &ht_in);
ht_ft = ht_in/12;
bmi = (703*wt_lb)/(ht_ft*ht_ft);
if (bmi < 18.5) {
printf("You have a BMI of %.lf, and your weight status is underweight\n" &bmi);
} else if (bmi >= 18.5 && bmi < 25) {
printf("You have a BMI of %.lf, and your weight status is normal\n", &bmi);
} else {
printf("You have a BMI of %.lf, and your weight status is overweight\n", &bmi);
}
}