MIT 6.189 A Gentle Introduction to Programming Using Python (OCW)14 Online
OpenStudy (anonymous):
can anyone tell me the problem of this programme?
#include
int main ()
{
double a,b,bmi;
printf("enter your weight(kg) and height(m)\n" ,a ,b);
scanf("%d%d" , &a ,&b);
bmi = a/(b*b);
printf("your BMI :\n" ,bmi);
if (bmi<18.5)
printf("you are under weight\n");
if (bmi>=18.5 && bmi<=24.9)
printf("you are normal\n");
if (bmi<=29.9 && bmi>=24.9);
printf("you are overweight\n");
if (bmi>=29.9)
printf("you are obese\n");
return 0;
}
Still Need Help?
Join the QuestionCove community and study together with friends!
Sign Up
OpenStudy (rsmith6559):
printf("enter your weight(kg) and height(m)\n" ,a ,b);
I see no reason for a and b in this statement.
scanf("%d%d" , &a ,&b);
%d is for integers, %f is for float. "%d%d" doesn't have any separation between the two numbers. "%d %d" separates the integers with a space.
if (bmi<=29.9 && bmi>=24.9);
if statements don't have a semi-colon.