## Question 1

Please input the bottom length of a triangle (integer). (output)

3 ⏎ (input)

Please input the height of the triangle (integer). (output)

4 ⏎ (input)

The area of the triangle is 6.00. (output)

#include<stdio.h>

int main (void) {
int bot_len, height;
double area;

printf("Please input the bottom length of a triangle (integer).\n");
scanf("%d", &bot_len);

printf("Please input the height of the triangle (integer).\n");
scanf("%d", &height);

area = (double) bot_len * (double) height / 2.0;
printf("The area of the traingle is %.2lf.\n", area);

return 0;
}


Download Q1.c

## Question 2

Please input your height (cm) and weight (kg). (output)

172.3 ⏎ (input)

65.0 ⏎ (input)

Your BMI is XXXX. (output)

The standard BMI is assumed to be 24.0. (output)

The difference with a standard weight is YYY kg. (output)

#include<stdio.h>

int main (void) {
double height, weight, BMI;
double height_meter, std_weight;

printf("Please input your height (cm) and weight (kg).\n");
scanf("%lf", &height);
scanf("%lf", &weight);

height_meter = height / 100.0;

BMI = (weight) / (height_meter * height_meter);
std_weight = 24.0 * (height_meter * height_meter);

printf("Your BMI is %.2lf.\n", BMI);
printf("The standard BMI is assumed to be 24.0.\n");
printf("The difference with a standard weight is %.2lf kg. \n", weight - std_weight);

return 0;
}

Download Q2.c