-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbmi2.c
More file actions
39 lines (34 loc) · 1.26 KB
/
bmi2.c
File metadata and controls
39 lines (34 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/*
Program to calculate the body mass index (BMI)
Written by: Alec
Wirrten on: Oct 2018
Written in: C
Compilied with: gcc
Version 1.8.1
*/
#include <stdio.h>
int main(void){
//Defines variables
//lbs = user weight | tli = user height in inches | bmi = body mass index | tlf = user height in feet
double lbs, tll, bmi, tli;
printf("**********************************\n* Welcome to the BMI Calculator. *\n**********************************"); //formatting
//Ask for user input and reads it
printf("\nPlease enter your weight in pounds (example: 130.4)\n");
scanf("%lf", &lbs);
printf("\nPlease enter your height in pounds \n(example: 71)\n");
scanf("%lf", &tli);
//BMI formula
bmi = ( lbs / (double)(tli * tli) ) * 703;
//If/else statement to device what weight category the person belongs in
printf("**********************************\n"); //formatting
if (bmi < 18.5) {
printf("BMI: %.1f\nStatus: Underweight\n",bmi);
} else if (bmi < 25.0) {
printf("BMI: %.1f\nStatus: Normal\n",bmi);
} else if (bmi < 30.0) {
printf("BMI: %.1f\nStatus: Overweight\n",bmi);
} else if (bmi >=30.0) {
printf("BMI: %.1f\nStatus: Obese\n",bmi);
}
printf("**********************************\n"); //formatting
}