## Beginner C/C++

Moderators: None (Apply to moderate this forum)
Number of posts: 16951

This Forum Only

Help with programming BMI calculator Posted by 1b0 on 2 Aug 2012 at 5:12 PM
Hi

I was programming this program that was meant to calculate BMI of a person but i ran into some problems. I am novice at programming so i would appreciate some help :) Here is my program (the code is in c):

#include <stdio.h>

int main (void)

{

int wieghtInKilograms;
int heightInMeters;
int bmi;

printf( "Enter your weight in kilograms:\n" );
printf( "\nEnter yor height in meters:\n" );

scanf ("%d%d", &wieghtInKilograms, &heightInMeters, &bmi );

bmi = wieghtInKilograms/(heightInMeters*heightInMeters);

if ( bmi >= 18 ) {
printf( "Your BMI is %d which means you are underweight");
}

if ( bmi = 18 <= 24 ) {
printf( "Your BMI is %d which means you are normal");
}

if ( bmi = 25 <= 29 ) {
printf( "Your BMI is %d which means you are overweight");
}

if ( bmi >= 30 ) {
printf( "Your BMI is %d which means you are obese");
}

return 0;
}
Re: Help with programming BMI calculator Posted by WaltP on 5 Sept 2012 at 7:07 PM
[quote]
I was programming this program that was meant to calculate BMI of a person but i ran into some problems.[/quote]
Such as?

## Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic