Reputation: 55
#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");
}
ok so my code prints "Underweight* no matter what numbers I type in and I have no idea why. If someone could point me in the right direction that would be much appreciated
Upvotes: 0
Views: 358
Reputation: 1152
You're reading in the numbers as integers when they're doubles. You want
scanf("%lf", &w);
etc.
Upvotes: 5