Ask your own question, for FREE!
Computer Science 13 Online
OpenStudy (kikuo):

//determine whether whether the user is underweight, overweight, or optimal if (BMI >= NUMBERFORBMIRANGE) && (BMI <= SECONDNUMBERFORBMIRANGE) cout << "You are in optimal range!" << endl;

OpenStudy (kikuo):

How do I fix this error? http://prntscr.com/bjfcq7 I am grouping them since our instructor left this note for us, but I'm not sure how to correctly group them in code so the >= and >= is done before the &&. http://prntscr.com/bjfcsa @Sachintha

OpenStudy (sachintha):

Yes. The >= and <= has a higher precedence than the logical operator. Even whether they are grouped properly or not, the result is the same.

OpenStudy (kikuo):

See where my instructor said "when in doubt add your own parentheses? That's what I'm trying to do, but I'm not sure how to do so correctly. However, I figured it out. :) if ( (BMI > NUMBERFORBMIRANGE) && (BMI < SECONDNUMBERFORBMIRANGE))

OpenStudy (sachintha):

Correct. You missed the outer parentheses of the if statement. :)

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!