2 Replies - 2358 Views - Last Post: 13 October 2012 - 08:21 AM Rate Topic: -----

#1 ioshi35  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • 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  Icon User is offline

  • void main'ers are DOOMED
  • member icon

Reputation: 1628
  • View blog
  • Posts: 3,090
  • 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  Icon User is offline

  • member icon


Reputation: 3993
  • View blog
  • Posts: 12,321
  • 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