Home Back

Bmi Calculator C Program Tutorial

BMI Formula:

\[ BMI = \frac{weight\ (kg)}{[height\ (m)]^2} \]

kg
meters

Unit Converter ▲

Unit Converter ▼

From: To:

1. What is BMI?

Body Mass Index (BMI) is a simple calculation using a person's height and weight. The formula is BMI = kg/m² where kg is a person's weight in kilograms and m² is their height in meters squared. BMI screens for weight categories that may lead to health problems.

2. How Does the Calculator Work?

The calculator uses the standard BMI formula:

\[ BMI = \frac{weight\ (kg)}{[height\ (m)]^2} \]

Where:

Explanation: The formula divides the weight by the square of the height to give a standardized measure of body weight relative to height.

3. BMI Categories

Standard BMI Categories:

4. Using the Calculator

Tips: Enter weight in kilograms and height in meters. For accuracy, measure height without shoes and weight with minimal clothing.

5. C Program Implementation

Simple C Program to Calculate BMI:

#include <stdio.h>

int main() {
    float weight, height, bmi;
    
    printf("Enter your weight in kg: ");
    scanf("%f", &weight);
    
    printf("Enter your height in meters: ");
    scanf("%f", &height);
    
    bmi = weight / (height * height);
    
    printf("Your BMI is: %.1f\n", bmi);
    
    if (bmi < 18.5) {
        printf("Category: Underweight\n");
    } else if (bmi < 25) {
        printf("Category: Normal weight\n");
    } else if (bmi < 30) {
        printf("Category: Overweight\n");
    } else {
        printf("Category: Obesity\n");
    }
    
    return 0;
}

How to Compile and Run:

  1. Save the code as bmi_calculator.c
  2. Compile with: gcc bmi_calculator.c -o bmi
  3. Run with: ./bmi

Bmi Calculator C Program Tutorial© - All Rights Reserved 2025