Help . BMI calculator in C language

Page 1 of 1

2 Replies - 11042 Views - Last Post: 13 October 2012 - 08:21 AMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'https://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=295466&amp;s=fa2222ae16c7ce585330d8070a147b48&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

#1 ioshi35

Reputation: 0
• Posts: 4
• Joined: 13-October 12

Help . BMI calculator in C language

Posted 13 October 2012 - 08:00 AM

Help me .. I'm having trouble about IF function . Help me how to fix the if function ..

this is my codes .

```int main () {

float H,W,BMI;

scanf("%f",&H);

scanf("%f",&W);

BMI = W/(H*H);
printf("%.2f",BMI);

if( BMI, 0 >= 18.5 ){
printf("\nYou are Underweight"); , Everytime is RUN it it shows all like "You are underweightYou are Normal
}
if( BMI , 18.5	 >= 25.98){
printf("You are Normal");
}
if(BMI ,25.99 >= 30.99){
printf("You are Overweight");
}
if( BMI > 30  ){
printf("You are Obese");
}

getch();

}
```

And I'm planning to make it a business .. Like

When the BMI is Underweight . I will serve a Healthy foods . Fruits and Vegetables
When the BMI is Normal . I will serve them Delicious Foods ..
When the BMI is Overweight . I Will serve them a Dietary Food .
When the BMI is Obese I will send them to GYM .

And it Cost everytime i Serve them

Give me idea . Help me in Coding PEACE im new here .. and I Just wanna make a business for my classmates .

This post has been edited by Salem_c: 13 October 2012 - 08:17 AM
Reason for edit:: added [code][/code] tags - learn to use them yourself

Is This A Good Question/Topic? 0

Replies To: Help . BMI calculator in C language

#2 Salem_c

• void main'ers are DOOMED

Reputation: 2161
• Posts: 4,228
• Joined: 30-May 10

Re: Help . BMI calculator in C language

Posted 13 October 2012 - 08:19 AM

> if( BMI, 0 >= 18.5
What are you trying here?

Perhaps something like
```if ( BMI >= 0 && BMI <= 18.5 ) {
}

```

#3 jimblumberg

Reputation: 5488
• Posts: 17,065
• Joined: 25-December 09

Re: Help . BMI calculator in C language

Posted 13 October 2012 - 08:21 AM

You can't concatenate conditionals in an if statement, you need both sides of the equation and you combine these equations with the logical operators:

```if(a == b || a == c)
//do something.
```

Jim

Page 1 of 1

 .related ul { list-style-type: circle; font-size: 12px; font-weight: bold; } .related li { margin-bottom: 5px; background-position: left 7px !important; margin-left: -35px; } .related h2 { font-size: 18px; font-weight: bold; } .related a { color: blue; }