Code:
12 #include <stdio.h> 13 #include <math.h>
14
15 int main()
16 {
20
21 double BMI, HEIGHT, WEIGHT, TargetBMI, IBW;
22 char Gender;
23
27 printf("Enter the height in inches.\n");
28 scanf("%lf", &HEIGHT);
29
30 printf("Enter the weight in pounds.\n\n");
31 scanf("\n%lf", &WEIGHT);
32
33 // to metric
34
35 {
36 WEIGHT = WEIGHT/2.2046;
37
38 HEIGHT = HEIGHT*0.0254;
39 }
// Calculate BMI
42
43 BMI = WEIGHT/(HEIGHT*HEIGHT);
44
47
61
62 // Ask for target BMI
63
64 printf("Enter the target BMI\n");
65 scanf("\n%lf", &TargetBMI);
66
67 // Compute Ideal Body Weight(IBW)
68
69 {
70 TargetBMI = TargetBMI*HEIGHT*HEIGHT;
71
72 TargetBMI = TargetBMI*2.2046;
73 }
74
75 // Display Ideal Body Weight(IBW)
76
77 printf("The target weight is %5.2f.\n\n", TargetBMI);
78
79 // Prompt user to enter the gender (F or M).
80
81 printf("Is the person Female or Male? Enter F or M:\n");
82 scanf("\n%c", &Gender);
83
84 //Returning HEIGHT variable to inches
85
86 HEIGHT=HEIGHT/.0254;
87
88
89 //Compute Ideal Body Weight Given Height and Gender & Convert IBW to pounds.
90
91
92 char F = 1;
93
94 if (Gender = 1)
95 {
96 IBW=HEIGHT-60;
97 IBW=IBW*2.3+45.5;
98 IBW=IBW*2.2046;
99 }
100
101 else
102 {
103 IBW=(HEIGHT-60)*2.3+50.0;
104 IBW=IBW*2.2046;
105 }
106
107
108 // Display IBW.
109
110 printf("The ideal weight is %5.2f.", IBW);
111
112 return 0;
113 }
Here is what I have.. if that helps you better understand what is happening.