BMI Calculator

Programming

This program calculates Body Mass Index (BMI) using the formula:

BMI = weight / height²

where weight is in kilograms and height is in meters.

Implementation

program bmi_calculator
    implicit none
    integer, parameter :: dp = kind(1.0d0)
    real(dp) :: weight, height, bmi

    print *, "Enter weight in kilograms:"
    read *, weight
    print *, "Enter height in meters:"
    read *, height

    bmi = weight / (height**2)
    print *, "Body Mass Index (BMI): ", bmi
end program bmi_calculator

Example Interaction

Enter weight in kilograms:
70
Enter height in meters:
1.75
Body Mass Index (BMI):    22.857142857142858