C language) How fat am I?? -->Let's check out BMI(Body Mass Index) using C language~!
Hi guys~~
I'm lulu:-)
Today I'm going to make a program that calculates our BMI.
#include <stdio.h>
int main()
{
double weight, height; //Declare variables to store our weight, height.
double bmi; //declare bariable to store our bmi.
printf("Input your weight(kg) : ");
scanf("%lf", &weight); //store the input weight in variable 'weight'
printf("Input your tall(cm) : ");
scanf("%lf", &height); //store the input height in variable 'height'.
height = height / 100; //bmi uses "meter", so we should change to meter.
bmi = weight / (height * height); //This is the formula of calculating BMI.
printf("Your BMI is : %.1lf\n", bmi);
if (bmi >= 20.0 && bmi < 25.0)
printf("Standard weight.\n");
else if (bmi < 20)
printf("Under weight.\n");
else
printf("Over weight.\n");
{
double weight, height; //Declare variables to store our weight, height.
double bmi; //declare bariable to store our bmi.
printf("Input your weight(kg) : ");
scanf("%lf", &weight); //store the input weight in variable 'weight'
printf("Input your tall(cm) : ");
scanf("%lf", &height); //store the input height in variable 'height'.
height = height / 100; //bmi uses "meter", so we should change to meter.
bmi = weight / (height * height); //This is the formula of calculating BMI.
printf("Your BMI is : %.1lf\n", bmi);
if (bmi >= 20.0 && bmi < 25.0)
printf("Standard weight.\n");
else if (bmi < 20)
printf("Under weight.\n");
else
printf("Over weight.\n");
return 0;
}
}
This way, we can easily know our BMI.
If you have any questions or opinions, tell me you'll be welcomed :-)
Comments
Post a Comment