Due: April 14, 2025
Points: 100
All programs are to be submitted through Gradescope. Gradescope will compile and execute your program, sometimes with varying inputs or invocations. You can see your score once executions are done. You can submit your program multiple times, up to the deadline — at that point, the score you have will usually be the grade for that problem. I say “usually” because we reserve the right to look at your submission and deduct points if you do not use proper programming style.
You have to name your program as given in the problem. Otherwise you will get an odd error message indicating there is a problem with Gradescope.
Also, your output must match Gradescope’s exactly, including blanks and tabs — so pay attention to the example output!
# # # OOOOO # X X # O O # X X # O O # X # O O # X X # OOOOO # X X # # ####################### # # # # # # # # # # # # # # ####################### # # # # # # # # # # # # # #When this is done, exit with the status code 0.
Call your program “tic.c”.
Here are some examples; each is a single execution of the program.
Height> 66 Weight> 190 The BMI for height 66 and weight 190 is 30.663452
Height> 48 Weight> 65 The BMI for height 48 and weight 65 is 19.832899
Height> 0 Height is not a positive integer
Height> 43 Weight> hello Weight is not a positive integer
Note that the program reads integers, but it prints the BMI as a floating point number. Remember to print the error messages on the standard error, and not the standard output.
Also notice that the program does not crash when I enter a non-integer (see the last example).
Call your program “bmi.c”.
Hint: Use scanf to read the input.
Here are some examples; as before, each is a single execution of the program.
Height> 66 Weight> 190 The BMI for height 66 and weight 190 is 30.663452 This is class I obese – but consult a doctor before doing anything!
Height> 48 Weight> 65 The BMI for height 48 and weight 65 is 19.832899 This is in a healthy range – but consult a doctor before doing anything!
Height> 72 Weight> 130 The BMI for height 72 and weight 130 is 17.629244 This is in a healthy range – but consult a doctor before doing anything!
Height> 72 Weight> 312 The BMI for height 72 and weight 312 is 42.310184 This is class III obese – but consult a doctor before doing anything!
Height> -1 Height is not a positive integer
Call your program “bmifull.c”.
So it should print this, where “␣” represents a single space and “↵” represents the newline. Note there is no trailing space after 96.
3␣6␣12␣24␣48␣96↵But it does not work. It doesn’t even compile! And the programmer didn’t comment anything. Your job: fix the program. Add comments, and in them identify the compile-time error(s) and the bug(s).
Call your fixed program three.c.
|
ECS 36A, Programming & Problem Solving Version of March 29, 2025 at 11:03PM
|
You can also obtain a PDF version of this. |