void main ()
{
float w;
float h;
cout<< "please enter your wiehgt \n";
cin>> w>>"\n";
cout<< "please enter your height \n";
cin>> h>>"\n";
cout<< "your BMI is: \n";
cout<< BMI (w,h)<<"and ur health status is: \n";
if (BMI<= 20) (error here on the operator "<=")
cout<< "you are underweight \n";
else if (BMI<=25) (error here on the operator "<=")
cout << "you are normal \n";
else if (BMI <= 31) (error here on the operator "<=")
cout << "you are overweight \n":
else if (BMI <= 100) (error here on the operator "<=")
cout << " obese \n";
else
cout<< "ERROR";
system ("pause");
}
The errors im getting on the operators are (operand types are incompatible)
That is one of the problems as mentioned above, you can't use >> to include a new line. You could put cout with \n after it to put a newline if you wanted to.
BMI is a function, to call it you need to include the () and the variables you are passing into it. For example
if (BMI(w,h)<= 20)
Otherwise you can set a variable equal to that function and just test that everytime in your if statements.
thx guys for the replies, but im still getting the same operators errors
it says exactly the following on each <=:
Error:operand types are incompatible ("float(*)(float w,float h)"and"int")
KhaledSH post your code again with updates and I will see (it works correctly for me after I change a : to ; in your code).
Marcos I thought he did include {} in his code at first but I was wrong (which is why I edited out my post). But if you only have a single statement after if statements/loops they will work correctly without the {}.
void main ()
{
float w;
float h;
cout<< "please enter your wiehgt \n";
cin>>w;
cout<< "please enter your height \n";
cin>> h;
cout<< "your BMI is: \n";
cout<< BMI (w,h)<<"and ur health status is: \n";
if (BMI<=20)
{
cout<< "you are underweight \n";
}
else if (BMI<=25)
{
cout << "you are normal \n";
}
else if (BMI <= 31)
{
cout << "you are overweight \n";
}
else if (BMI <= 100)
{
cout << " FAT!!!! \n";
}
else
{
cout<< "EROR";
}