2013-01-21 137 views
0
#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"); 
} 

好了,所以我的代码打印“减持*不管我输入什么号码,我不知道为什么。如果有人能指出我将不胜感激正确的方向BMI计算器不工作

回答

5

你在数作为整数读书时,他们会加倍。你想

scanf("%lf", &w);

+0

谢谢!它现在:)正如你可能会说我只是学习C – user1984103

+0

不要忘记接受! –

+0

@ user1984103阅读您的C书和/或C参考。那里描述了'scanf()'和'%lf'! –