I am trying to convert units in order to calculate BMI. I am having some difficulties and I would appreciate it if someone can guide me.
Code:
#include <stdio.h>
#include <math.h>
int main(void)
{
char weight,height;
double h,b;
int w;
printf("Enter the body weight:");
scanf("%d%s",&w,weight);
printf("Enter the height:");
scanf("%lf%s",&h,height);
if(weight==lb && height==ft){
b=floor((double)w*0.4536)/(pow((h*3.28),2));
printf("\nThe Body Mass Index (BMI) is: %.1f\n",b);
}else if(weight==lb && height==in){
b=floor((double)w*0.4536)/(pow((h*39.37),2));
printf("\nThe Body Mass Index (BMI) is: %.1f\n",b);
}else if(weight==kg && height==ft){
b=floor((double)w)/(pow((h*3.28),2));
printf("\nThe Body Mass Index (BMI) is: %.1f\n",b);
}else if(weight==kg && height==mt){
b=floor((double)w)/(pow((h*1),2));
printf("\nThe Body Mass Index (BMI) is: %.1f\n",b);
}else if(weight==kg && height==in){
printf("\nThe Body Mass Index (BMI) is: %.1f\n",b);
b=floor((double)w)/(pow((h*39.37),2));
}else if(weight==lb && height==mt){
b=floor((double)w*0.4536)/(pow((h*1),2));
printf("\nThe Body Mass Index (BMI) is: %.1f\n",b);
}
printf("Category:");
if(b<16.5) {
printf("Severly underweight\n");
} else if( 16.5<=b && 18.5>b) {
printf("underweight\n");
} else if( 18.5<=b && 25.0>b) {
printf("Normal\n");
} else if(25.0<=b && 30.0>b) {
printf("Overweight\n");
} else if(30.0<=b) {
printf("Obese\n");
}
return 0;
}