-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBMI.c
More file actions
38 lines (30 loc) · 791 Bytes
/
BMI.c
File metadata and controls
38 lines (30 loc) · 791 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
30
31
32
33
34
35
36
37
38
#include <stdio.h>
void calculate_bmi(float weight, float height) {
if (height <= 0) {
printf("Height must be greater than zero.\n");
return;
}
float bmi = weight / (height * height);
printf("Your BMI is: %.2f\n", bmi);
if (bmi < 18.5) {
printf("Category: Underweight\n");
}
else if (bmi >= 18.5 && bmi < 24.9) {
printf("Category: Normal weight\n");
}
else if (bmi >= 24.9 && bmi < 29.9) {
printf("Category: Overweight\n");
}
else {
printf("Category: Obesity\n");
}
}
int main() {
float weight, height;
printf("Enter weight (kg): ");
scanf("%f", &weight);
printf("Enter height (meters): ");
scanf("%f", &height);
calculate_bmi(weight, height);
return 0;
}