-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchecker.c
54 lines (48 loc) · 1.4 KB
/
checker.c
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include <stdio.h>
#include <stdlib.h>
void calculator(double Weight, double Height);
int main(void)
{
printf("Check BMI, Ready?(Y/N): ");
char checking;
scanf(" %c", &checking);
if(checking == 'y' || checking == 'Y'){
int count = 1;
while(count <= 10){
printf("Weight (KG): ");
double weight;
scanf("%lf", &weight);
printf("Height (CM): ");
double height;
scanf("%lf", &height);
calculator(weight, height); // call the function
printf("Again?(Y/N): ");
char again;
scanf(" %c", &again);
if(again == 'Y' || again == 'y') {
system("clear");
continue;
} else {
break; // break the programe
}
count += 1;
}
} else {
printf("Bye!\n");
}
return 0;
}
void calculator(double Weight, double Height) {
double CM_to_M = Height / 100.0;
double power_of_height = CM_to_M * CM_to_M;
double calculate = Weight / power_of_height;
if(calculate <= 18.5){
printf("BMI is ( %0.2f ) Underweight!\n", calculate);
} else if(calculate >= 18.6){
printf("BMI is ( %0.2f ) Normal!\n", calculate);
} else if(25.0 <= calculate) {
printf("BMI is ( %0.2f ) Overweight!\n", calculate);
} else if(calculate >= 30.0){
printf("BMI is ( %0.2f ) Obese!\n", calculate);
}
};