luc022.c¶
Problem Statement
The Body Mass Index (BMI) is defined as ratio of weight of the person (in Kilograms) to square of the height (in meters). Write a program that receives weight and height, calculate the BMI, and reports the BMI catagory as per the following table. BMI Catagory BMI Starvation < 15 Anorexic 15.1 to 17.5 Underweight 17.6 to 18.5 Ideal 18.6 to 24.9 Overweight 25 to 25.9 Obese 30 to 39.9 Morbidly Obese >= 40
Metadata¶
| Property | Detail |
|---|---|
| Author | Amit Dutta amitdutta4255@gmail.com |
| Date | 12 Dec 2025 |
| License | MIT License (See the LICENSE file for details) |
| Difficulty | Beginner (index: 1 / 10) |
Concepts¶
Beta Feature
This concept detection system is still in beta and may occasionally show incorrect or incomplete results.
- Recursion
- Pointers
Actions¶
You can print or save this file by opening Raw and using your browser.
Source Code¶
#include <stdio.h>
int main()
{
double weight, height, bmi;
printf("Enter your Weight (in Kilograms) and Height (in Meters) : ");
scanf("%lf %lf", &weight, &height);
bmi = weight / (height * height);
printf("\nCalculated BMI : %g", bmi);
if (bmi < 15)
printf("\nBMI Catagory : Starvation");
else if (bmi >= 15.1 && bmi <= 17.5)
printf("\nBMI Catagory : Anorexic");
else if (bmi >= 17.6 && bmi <= 18.5)
printf("\nBMI Catagory : Underweight");
else if (bmi >= 18.6 && bmi <= 24.9)
printf("\nBMI Catagory : Ideal");
else if (bmi >= 25 && bmi <= 25.9)
printf("\nBMI Catagory : Overweight");
else if (bmi >= 30 && bmi <= 39.9)
printf("\nBMI Catagory : Obese");
else if (bmi >= 40)
printf("\nBMI Catagory : Morbidly Obese");
else
printf("\nBMI Catagory : Unclassified");
return 0;
}
Explanation¶
Explain with AI
Copy the prompt below and paste it into any AI assistant.
You are explaining a C programming code to a beginner.
STRICT RULES:
- Only use the given code. Do NOT assume anything not present.
- Do NOT add extra examples.
- Keep explanation clear and short.
- If something is unclear, say "Not clear from code".
- Follow the exact format below. Do NOT change headings.
FORMAT:
[START]
## What it does
(Explain the overall purpose in 1-2 sentences)
## Step-by-step
(Explain how the code works in steps, simple language)
## Key Concepts
(List concepts like loop, condition, function, etc.)
## Notes
(Mention any limitations, errors, or assumptions)
[END]
CODE (luc022.c):
#include <stdio.h>
int main()
{
double weight, height, bmi;
printf("Enter your Weight (in Kilograms) and Height (in Meters) : ");
scanf("%lf %lf", &weight, &height);
bmi = weight / (height * height);
printf("\nCalculated BMI : %g", bmi);
if (bmi < 15)
printf("\nBMI Catagory : Starvation");
else if (bmi >= 15.1 && bmi <= 17.5)
printf("\nBMI Catagory : Anorexic");
else if (bmi >= 17.6 && bmi <= 18.5)
printf("\nBMI Catagory : Underweight");
else if (bmi >= 18.6 && bmi <= 24.9)
printf("\nBMI Catagory : Ideal");
else if (bmi >= 25 && bmi <= 25.9)
printf("\nBMI Catagory : Overweight");
else if (bmi >= 30 && bmi <= 39.9)
printf("\nBMI Catagory : Obese");
else if (bmi >= 40)
printf("\nBMI Catagory : Morbidly Obese");
else
printf("\nBMI Catagory : Unclassified");
return 0;
}