BMI计算器不工作

时间:2013-01-21 06:40:33

标签: c

#include <stdio.h>
#include <stdlib.h>
int main() {
    double w, h, b;
    printf("Enter your weight in pounds \n");
    scanf("%d", &w);
    printf("Enter your height in inches \n");
    scanf("%d", &h);
    h = h/12;
    b = w*703 / (h*h);
    if (b < 18.5) {
        printf("underweight");
    } else if (b>=18.5 && b<25) {
        printf("normal");
    } else {
        printf("overweight");
    }
    system("Pause");
}

好吧所以我的代码打印“体重不足*无论我输入什么数字,我都不知道为什么。如果有人能指出我正确的方向,将非常感激

1 个答案:

答案 0 :(得分:5)

当你的双打时,你正在读数字作为整数。你想要

scanf("%lf", &w);

相关问题