I want the function getCategory() to return "invalid" , instead of printing the word "invalid" (i.e instead of using printf ) when input to the function is invalid (i.e.when either height or weight are lower then zero). please help:
#include<stdio.h>
#include<conio.h>
char getCategory(float height,float weight)
{
char invalid = '\0';
float bmirange;
if(height<=0 || weight<=0)
return invalid;
else
{
height=height*0.01;
bmirange=[weight/(height*height)];
if(bmirange< 15 )
return starvation;
}
}
/* return the following to category
If bmi range < 15 then category is "starvation"
If bmi range >=15 && bmi range < 18.5 then category is "underweight"
If bmi range >=18.5 && bmi range < 25 then category is "normal"
If bmi range >= 25 && bmi range < 30 then category is "overweight"
If bmi range >=30 && bmi range < 40 then category is "obese"
If bmi range >=40 then category is "morbidly obese
*/
int main()
{
char Category;
float height,weight;
printf("enter height");
scanf("%f",&height);
printf("enter weight");
scanf("%f",&weight);
Category=getCategory(height,weight);
if(Category == 0)
printf("invalid");
else
printf("%c", Category);
}