Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Objectives 1) Learn basic input with scanf 2) Learn printf formatting 3) Learn b

ID: 2248516 • Letter: O

Question

Objectives 1) Learn basic input with scanf 2) Learn printf formatting 3) Learn basic computation using operators Description In this programming assignment you will code a basic body mass index calculator (BMI). The calculator will prompt for the user's first and last name, the user's height in inches, and the user's weight in pounds. Tasks 1. The program will prompt for the user's first and last name 2. The program will prompt for the user's height in inches, and weight in pounds These values will be whole numbers 3. The program will compute the user's BMI. This will include some metric conversion and you will have to research the formula for BMI 4. The program will display the results as shown in the following example. You must include the "number" bar which will assist in grading. 5. Field widths and formatting for all output values must match the following output exactly. For example, the BMI must have one significant decimal place, there should be no space between the feet and inches output (5'9"). The first and last names are printed in a 20 character field and have opposite justification (left, right) $./a.out Enter your first and last name Donald Trump Enter (int) height in inches and (int) weight in lbs 72 190 01234567890123456789012345678901234567890123456789 Donald 72 inches is 6'0" Trump, Your BMI is 25.8

Explanation / Answer

#include <stdio.h>
#define FEETTOMETER 0.3048
int main() {
float weight, height, bmi;

/* get the input weight from the user */
printf("Enter your weight(in kgs):");
scanf("%f", &weight);

/* get the input height from the user */
printf("Enter your height(in feet):");
scanf("%f", &height);

/* height in meters */
height = height * FEETTOMETER;

/* bmi calculation */
bmi = (weight)/(height * height);

/* print the result */
printf("Your Body Mass Index: %f ", bmi);
return 0;
}