Question

Write a C program that reads the height and weight of a person and calculates the...

Write a C program that reads the height and weight of a person and calculates the body mass index (bmi) according to formula bmi = weight/(height)2. Your program should display a qualitative assessment of the weight according to the following table:

BMI value
Letter Grade
[0-20)
Below normal weight
[20-25)
Normal weight
[25-30)
Overweight
>=30
Obese

Sample Output:
Enter your weight in kilos: 70
Enter your height in meters: 1.80
Result: Normal weight
Test values: (70 1.8) (50, 1.9) (90, 1.6), (140, 1.7) 

in c code

0 0
Add a comment Improve this question Transcribed image text
Answer #1

**********************************************************************************************

Please find the below program

**************************************************************************************************

#include <stdio.h>
int main()
{
float weight, height; //declare the variables to store weight and height
int bmi; //declare the variable to store the body mass value
printf("Enter the weight in kgs:");
scanf("%f", &weight); //read the value for weight
printf("Enter the height in meters:");
scanf("%f", &height); //read the value for height
bmi = weight / (height * height); //calculating the body mass value
if(bmi > 0 && bmi < 20) //checking the bmi value less than 20
{
printf("Result:Below Normal Weight");
}
else if(bmi >20 && bmi < 25)//checking the bmi value is between 20 and 25
{
printf("Result: Normal Weight");
}
else if(bmi>25 && bmi<30)//checking the bmi value is between 25 and 30
{
printf("Result: Overweight");
}
else //the value is greater than or equal to 30
{
printf("Result: Obese");
}
return 0;
}
*****************************************************************************************************************************

Please find the attached screenshoot for you reference

*****************************************************************************************************************************

**********************************************************************************************************************************************

testvalue 1

**********************************************************************************************************************************************

testvalue 2

**********************************************************************************************************************************************

testvalue 3

**********************************************************************************************************************************************

testvalue 4

**********************************************************************************************************************************************

Add a comment
Know the answer?
Add Answer to:
Write a C program that reads the height and weight of a person and calculates the...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • read instructions carefully please matlab only Write a MATLAB function for a BMI calculator that receives the inputs for body weight (lbs)and height (ft) from the user's program, calculates th...

    read instructions carefully please matlab only Write a MATLAB function for a BMI calculator that receives the inputs for body weight (lbs)and height (ft) from the user's program, calculates the BMI using the equation below, displays the BMI category, and outputs the BMI value tothe user's program W (kg) h2 (m2) BMI Display Normal if 18.5 s BMI 25 Display Overweight if 25 s BMI <30 Display Obese if BMI 2 30 Else display underweight So you will create two...

  • /////////////////////////////////////////////////////////////////////////////////// //This program // 1. asks the user her/his weight and height // 2. then calculates...

    /////////////////////////////////////////////////////////////////////////////////// //This program // 1. asks the user her/his weight and height // 2. then calculates the user's body-mass-index (BMI) // 3. and then prints an appropriate message based on the user's BMI /////////////////////////////////////////////////////////////////////////////////// #include <iostream> using namespace std; void printWelcome(); // ask the weight (in pounds) and height (in inches) of the user and store the values in formal // parameters weight and height, respectively void getWeightAndHeight(float& weight, float& height); // calculate and return the BMI (Body-Mass-Index) based on...

  • Check the given program for errors and write the correct program : height = float(input("Enter height...

    Check the given program for errors and write the correct program : height = float(input("Enter height in meters: ")) weight = float(input("Enter weight in kg: ")); bmi == weight/(height**2) print("Your BMI is:”,bmi”) if ( bmi< 16) print("severely underweight") elif ( bmi>= 16 and bmi< 18.5): print("underweight") elif ( bmi>= 18.5 and bmi< 25): print("Healthy") elif ( bmi>= 25 and bmi< 30): print("overweight") elif ( bmi>=30): print("severely overweight") elseif: print(“Not in Range) Rewrite the entire program correctly and calculate the bmi...

  • I have this C program that calculates an input and converts it to a BMI calculation....

    I have this C program that calculates an input and converts it to a BMI calculation. Any idea how this would look as an LC3 program? I'm taking an LC3 programming class next semester and want an idea of what this code would even translate to, just trying to get a head start. I'm more so curious on how to get user input in a LC3 program, then I can try myself and figure it out from there. int main()...

  • OGICAL 28. Body mass index (BMI) is a measure of obesity. In standard units, it is...

    OGICAL 28. Body mass index (BMI) is a measure of obesity. In standard units, it is calculated by the formula EMENTS BMI = 7032 ATEMENT NESTED INTS where Wis weight in pounds, and His height in inches. The obesity classification is BMI Classification Below 18.5 Underweight 18.5 to 24.9 Normal 25 to 29.9 Overweight 30 and above Obese Tue Write a program in a script file that calculates the BMI of a person. The program asks the person to enter...

  • Write a program (code) that performs the following: Height and Weight for Male and Female: Robinson...

    Write a program (code) that performs the following: Height and Weight for Male and Female: Robinson formula to calculate the body relative to the height in inches is as follow: Ideal weight in kilogram = 52 + 1.9 * (height - 60) for male Ideal weight in kilogram = 49 + 1.7 * (height - 60) for female Write a program that prompts the user to enter the gender ('M' or 'm' for male and 'F' or feet and inches,...

  • Body Mass Index Calculator

    Create a BMI calculator applications that reads the user's weight in kilograms and height in meters, then calculates and displays the user's body mass index.Also, the application should display the following information from the Department of Health and Human Services, so the user can evaluate his/her BMI:BMI ValuesUnderweight: less that 18.5Normal: between 18.5 and 24.9Overweight: between 25 and 29.9Obese: 30 or greaterFormula for calculating BMI areBMI = weightInKilogramsheightInMeters x heightInMetersThe program is to be written in C++ langauge.I need some...

  • Write a Java program that performs these operations Prompt the user to enter a low height...

    Write a Java program that performs these operations Prompt the user to enter a low height in feet (an integer) Prompt the user to enter a high height in feet (an integer) Prompt the user to enter a low weight in pounds (an integer) Prompt the user to enter a high weight in pounds (an integer) Print a table of Body Mass Index (BMI) for the heights and weights entered, ranging from the low height to the high height (inclusive),...

  • BMI Class. Using JAVA write Object Oriented Programming by creating class, object and method , that...

    BMI Class. Using JAVA write Object Oriented Programming by creating class, object and method , that takes users' input (weight and Height) and calculates the BMI. If the result is less than 18.5 display "you are underweight", if the result is greater than 18.5 display "you have a normal weight", if the result is greater than 24.9 display "your weight is considered overweight", and the result is greater than 30 display "your weight is considered as obese" (BMI = 703...

  • 1. Your Body Mass Index (BMI) is a measure of your weight relative to your height....

    1. Your Body Mass Index (BMI) is a measure of your weight relative to your height. The formula can be found here: http://www.whathealth.com/bmi/formula.html (use the Imperial U.S. Method). Write an algorithm in pseudocode to calculate and display a person's BMI accepting as input their height in feet and inches and their weight in pounds. The output of your algorithm should be as follows: a. BMI b. A statement of whether the result is underweight, normal, overweight or obese.

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT