[Tutorial 7] 13.Enter the name, height, weight and gender of a person and calculate his/her BMI in Kg. BMI = weight/ height2

#include <stdio.h>
int main()
{
char name[50], gender;
float height, weight, bmi;

/* Input data from user */
    printf("Enter name: ");
    scanf("%s", name);
    printf("Enter height in meters: ");
    scanf("%f", &height);
    printf("Enter weight in kilograms: ");
    scanf("%f", &weight);
    printf("Enter gender (M/F): ");
    scanf(" %c", &gender); 

/* Calculate BMI*/
    bmi = weight / (height * height);

/* Display the result*/
    printf("\n%s's BMI: %.2f\n", name, bmi);

return 0;
}

This C program prompts the user to input a person's name, height (in meters), weight (in kilograms), and gender (M/F). It then calculates the Body Mass Index (BMI) using the formula BMI = weight / (height * height) and displays the result. By incorporating user input and basic arithmetic operations, the program swiftly computes the BMI, offering a practical tool for assessing an individual's health status based on their weight and height.

Comments

Popular posts from this blog

Introduction To C

First C Program

Compilation process in c