-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbmi.c
More file actions
29 lines (25 loc) · 827 Bytes
/
bmi.c
File metadata and controls
29 lines (25 loc) · 827 Bytes
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
#include <stdio.h>
/*
TODO:
Create a BMI calculator that reads the users weight in kilos and height in meters
then calculates and displays the body mass index
BMI = weightInKilos / (heightInMeters * heightInMeters)
*/
int main (void){
float weight, height, bmi;
printf("%s", "Enter your height (m): ");
scanf("%f", &height);
printf("%s", "Enter your weight(kg): ");
scanf("%f", &weight);
bmi = weight / (height * height);
printf("%s%0.2f\n", "You have a BMI of: ", bmi);
if(bmi < 18.5) {
printf("%s", "You are underweight\n");
}else if (bmi > 18.5 && bmi < 25) {
printf("%s", "Your weight is normal\n");
} else if (bmi >= 25 && bmi < 30) {
printf("%s", "You are overweight!\n");
}else {
printf("%s", "You are obese!\n");
}
}