How to use if elseif, if
Show older comments
Underweight: BMI is less than 18.5 Normal weight: BMI is 18.5 to 24.9 Overweight: BMI is 25 to 29.9 Obese: BMI is 30 or more how to use if, elseif, if to Display BMI classification I did:
if(BMI<18.5)
BMI classification='underweight'
elseif(18.5<BMI<24.9)
BMI classification='Normal weight'
else(25<BMI<29.9)
BMI classification='Overweight'
end
Answers (1)
Youssef Khmou
on 11 Feb 2013
Hi try this :
BMI=input(' Enter BMI : ');
if(BMI<18.5)
classification='underweight'
elseif(18.5<BMI && BMI<24.9)
classification='Normal weight'
else(25<BMI && BMI<29.9)
classification='Overweight'
end
2 Comments
THANH NGUYEN
on 11 Feb 2013
Image Analyst
on 11 Feb 2013
Edited: Image Analyst
on 11 Feb 2013
if BMI < 18.5
classification='underweight'
elseif 18.5 <= BMI && BMI < 24.9
classification='Normal weight'
elseif 24.9 <= BMI && BMI < 30
classification='Overweight'
else
classification='Obese'
end
Categories
Find more on Octave in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!