C program to calculate Body Mass Unit
Before coding the C program to calculate Body mass index (BMI), we have to knowledge about BMI
Body mass index (BMI) is a measure of fat on the basis of
height and weight and that apply to men and women.
How to calculate BMI
The formula of BMI = weight (in k. g.)/
C program to calculate Body Mass Unit (BMI) (When weight in K. g. )
|
#include<stdio.h> #include<conio.h> void main() { float w, m, bmi, d; // taking input of weight in kg from users printf("\n Enter weight (in kg)"); scanf("%f", &w); // taking input of height in meter from users printf("\n Enter height (in
meter)"); scanf("%f", &m); // calculating m d=m*m; // using formulat of BMI bmi=w/d; // printing Body Mass Index printf("\n Body mass index (BMI) is
%f", bmi); getch(); } |
Output
C program to calculate Body Mass Unit (BMI) (When weight in feet )
We need height in meter to calculate BMI and if the height in
feet first we change height feet into the meter
How to convert feet into the meter
1 feet = 30.48 centimeter
And, 100 centimeter = 1 meter
For example,
6 feet = 30.48 *
6 = 182.88 cm
182.88 cm = 182.88/100
= 1.8288
meter
Program
|
#include<stdio.h> #include<conio.h> void main() { float w, h, c, m, bmi, d; // taking weight (in kg) input from user printf("\n Enter weight (in kg)"); scanf("%f", &w); //taking height (in feet) input from user printf("\n Enter height (in
feet)"); scanf("%f", &h); // converting feet into centimeters (1 f =30.48 cm) c=h*30.48; //converting centimeters into meters (1 m =100 cm) m=c/100; // finding (meter)2 d=m*m; // using bmi=kg/(meter)2 formula bmi=w/d; // printing BMI printf("\n Body mass index (BMI) is
%f", bmi); getch(); } |
C program to calculate Body Mass Unit (BMI) (When weight in feet )
We need height in meter to calculate BMI and if the height is in Centimeter,
we change cm into the meter
How to convert CM into the meter
1oo centimeter = 1 meter
Centimeter = cm / 100
For example
150 cm = 150/100
= 1.5 meter
Program
|
#include<stdio.h> #include<conio.h> void main() { float w, h, m, bmi, d; // taking weight (in kg) input from user printf("\n Enter weight (in kg)"); scanf("%f", &w); //taking height (in cm) input from user printf("\n Enter height (in cm)"); scanf("%f", &h); // converting centimeters into meter m=h/100; // finding (meter)2 d=m*m; // using bmi=kg/(meter)2 formula bmi=w/d; // printing Body mass index printf("\n Body mass index (BMI) is
%f", bmi); getch(); } |
Output




0 Comments
Please do not enter any spam link on comment box