Help . BMI calculator in C language

Page 1 of 1

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

#1 ioshi35

• New D.I.C Head

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;

printf("Enter your height in Meters");
scanf("%f",&H);

printf("Enter your weight in Kilograms");
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: 1418
• Posts: 2,681
• 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 ) {
}

```

Was This Post Helpful? 0

#3 jimblumberg

Reputation: 3054
• Posts: 9,291
• 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
Was This Post Helpful? 0

Page 1 of 1

 Query failed: connection to localhost:3312 failed (errno=111, msg=Connection refused).