This question already has an answer here:
- C: What does if(a<b<c) do? [duplicate] 3 answers
Regardless of the value for BMI, it always prints "You're BMI shows you are very severely underweight". Whats wrong with the code?
I've tried many things.
{
float weight;
printf("\nPlease enter your body weight in Kgs: ");
scanf("%f",&weight);
float height;
printf("\nPlease enter your height in meters,N: ");
scanf("%f",&height);
float bmi = weight/pow(height,2);
printf("Your BMI is = %.2f.\n",bmi);
if (14<=bmi<15) {
printf("You're BMI shows you are very severely underweight.\n");
}
else if (15<= bmi <16) {
printf("You're BMI shows you are severely underweight.\n");
}
else if (16<= bmi <18.5) {
printf("You're BMI shows you are underweight.\n");
}
else if (18.5<= bmi <25) {
printf("You're BMI shows you are a healthy weight.\n");
}
else if (25<= bmi <30) {
printf("You're BMI shows you are overweight.\n");
}
else if (30<= bmi <35) {
printf("You're BMI shows you are Obese class one.\n");
}
else
printf("You're BMI shows your a fat bastard.\n");
printf("end");
}
Expected: If i got a BMI of 33, I would expect it to print "You're BMI shows you are Obese class one." Actual: It prints "You're BMI shows you are very severely underweight."
Aucun commentaire:
Enregistrer un commentaire