Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
55 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Body Mass Index (BMI) Calculator | ||
|
||
Determine wether you're Underweight, Normal weight, Overweight, Obesity, or Over Obesity based on your body mass index, which is calculated by using weight and height. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/*################################################### | ||
# # | ||
# Body Mass Index (BMI) Calculator # | ||
# Copyright (c) 2008 - 2018 Junian Triajianto # | ||
# # | ||
###################################################*/ | ||
|
||
#include <cstdio> | ||
#include <cstdlib> | ||
|
||
char toUpper(char x); | ||
|
||
int main() { | ||
char r; | ||
do { | ||
float TB, IMT; | ||
int BB; | ||
printf("Body Mass Index (BMI) Calculator\n"); | ||
printf("================================\n\n"); | ||
printf("BW : Weight (kg)\n"); | ||
printf("BH : Height (m)\n"); | ||
printf("BMI : Body Mass Index\n\n"); | ||
printf("BW : "); | ||
scanf("%d", & BB); | ||
printf("BH : "); | ||
scanf("%f", & TB); | ||
IMT = BB / (TB * TB); | ||
printf("BMI : %0.2f\n\n", IMT); | ||
printf("You are "); | ||
if (IMT < 18.5) | ||
printf("Underweight"); | ||
else if (IMT < 23) | ||
printf("Normal weight"); | ||
else if (IMT < 25) | ||
printf("Overweight"); | ||
else if (IMT < 30) | ||
printf("Obesity"); | ||
else | ||
printf("Over Obesity"); | ||
printf("\n\nTry again [Y/N]? "); | ||
do { | ||
r = getchar(); | ||
r = toUpper(r); | ||
} while (r != 'Y' && r != 'N'); | ||
} while (r == 'Y'); | ||
return 0; | ||
} | ||
|
||
char toUpper(char x) { | ||
if (x >= 97 && x <= 122) x = x - 32; | ||
return x; | ||
} |
67abee3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
amazing!!