//determine whether whether the user is underweight, overweight, or optimal if (BMI >= NUMBERFORBMIRANGE) && (BMI <= SECONDNUMBERFORBMIRANGE) cout << "You are in optimal range!" << endl;
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
Yes. The >= and <= has a higher precedence than the logical operator. Even whether they are grouped properly or not, the result is the same.
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))
Correct. You missed the outer parentheses of the if statement. :)
Join our real-time social learning platform and learn together with your friends!