Algorithm
problem Link ; https://www.codechef.com/problems/BMI
Problem
Read problems statements in Hindi, Mandarin Chinese, Vietnamese, and Bengali as well.
You are given the height (in metres) and mass (in kilograms) of Chef. The Body Mass Index (BMI) of a person is computed as .
Report the category into which Chef falls, based on his BMI:
- Category 1: Underweight if BMI
- Category 2: Normal weight if BMI , ,,
- Category 3: Overweight if BMI , ,,
- Category 4: Obesity if BMI
###Input:
- The first line of input will contain an integer, , which denotes the number of testcases. Then the testcases follow.
- Each testcase contains a single line of input, with two space separated integers, , which denote the mass and height of Chef respectively.
###Output: For each testcase, output in a single line, or , based on the category in which Chef falls.
###Constraints
- Its guaranteed that divides .
Sample 1:
3 72 2 80 2 120 2
1 2 4
Explanation:
Case 1: Since , therefore person falls in category .
Case 2: Since , therefore person falls in category .
Case 3: Since , therefore person falls in category .
Code Examples
#1 Code Example with C Programming
Code -
C Programming
#include<stdio.h>
int main()
{
int h,m,t,bmi;
scanf("%d",&t);
while(t--)
{
scanf("%d %d",&m,&h);
bmi=(m/(h*h));
if(bmi < =18 && bmi>0) printf("1\n");
else if(bmi<=24) printf("2\n");
else if(bmi < =29) printf("3\n">;
else if(bmi>=30) printf("4\n");
}
}
Copy The Code &
Try With Live Editor
Input
72 2
80 2
120 2
Output
2
4
Demonstration
CodeChef solution BMI - Body Mass Index Codechef solution in C,C++