#include<stdio.h>
int main()
{
float h,w,x;
printf("Enter your height and weight");
scanf("%f %f",&h,&w);
w/(h*h)==x;
scanf("%f",&x);
if(x<=18.5)
{printf("You are UNDER WEIGHT");
}
else if("x==(18.5&&24.9)")
{printf("You are AVERAGE");
}
else if("x>=(25&&29.9)")
{printf("You are OVER WEIGHT");
}
else
{printf("OBESITY!!!");
}
return 0;
}
我是编程的初学者。我想使用嵌套的if else语句来做一个复杂的程序。但是我不能执行上面的代码。你能帮助我吗 ? 对不起,我很笨。提前致谢 :)
最佳答案
更改
w/(h*h)==x;
scanf("%f",&x);
至
if(h) //if h is not zero
x=w/(h*h); //calculate x
还有这些
else if("x==(18.5&&24.9)")
else if("x>=(25&&29.9)")
至
else if(x>18.5 && x<=24.9)
else if(x>=25 && x<=29.9)