Beginner C/C++

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

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
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;
}
Report
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
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.