Write a Fortran 77 program that inputs three weights and heights and outputs three body mass indices (BMIs), one corresponding to each (weight, height) input pair. Process the three input pairs with a "do" loop. Compute BMI with the following formula: (weight * 703) / height^2. Fortran has an exponentiation operator, which you MUST use. Print calculated BMIs to two decimal places using a format statement.
Include a function named "calcBmi" to compute BMI given a weight in pounds and height in inches. Your function should return the computed BMI using a floating-point type.
Include a comment block at the top of the program and other comments in your code. Also, split at least one statement across two lines.
Lastly, answer the questions below.
RESTRICT your Fortran code to the Fortran 77 standard. Your program MUST translate successfully with "f2c". Do NOT code your program entirely in uppercase as it is detrimental to readability and NOT required by "f2c".
Input three weights and three heights. Weight will be in pounds and height will be in feet and inches. All inputs will be integers. Feet and inches will be typed on the same line.
Output the BMI using a field width of five with two decimal places.
Use PRECISELY the format shown below with the EXACT same spacing and spelling.
Sample Input and Output
Weight ==> 200 Height ==> 6 4 BMI = 24.34 Weight ==> 180 Height ==> 6 0 BMI = 24.41 Weight ==> 190 Height ==> 6 1 BMI = 25.06
Answer these questions in a PLAIN TEXT file named "README.txt". Include the QUESTIONS in the file as well. Use whitespace for readability, and keep lines to AT MOST 80 characters.
Fortran uses pass by reference. How does this manifest in the C code?
What C type does "real" correspond to on OUR systems? How do you know?
What does MAIN__ represent and how does it get executed? Where, precisely, are symbols like do_lio defined?
Discuss at least TWO of the "unpleasant" lexical features of Fortran 77?
Discuss the readability and efficiency of the generated code. Were any inefficiencies introduced, or optimizations performed? Experiment by modifying your Fortran code to see how the translated code changes.
Submit your Fortran code (use a ".f" extension), generated C code, and "README.txt".
The source code for "f2c" is HERE.
To compile your Fortran program use the "f2c" translator to produce C code. Then use "gcc" to produce an executable. View the generated C code for link switches you must pass to "gcc".
You may find this Fortran 77 Tutorial helpful.
"gcc" will produce a couple warnings when you compile the generated code.