COMP-051: Mock Midterm 3, Modules 1-6 Matches: Midterm3-Modules1-6.txt (questions), 5 points each, 100 total. ================================================================ PART 1: MULTIPLE CHOICE ANSWERS ================================================================ 1. C 10. B 2. A 11. D 3. D 12. A 4. A 13. C 5. B 14. B 6. D 15. D 7. B 16. A 8. A 17. C 9. C 18. B ================================================================ PART 2: WRITE THE FUNCTION, GRADING GUIDE ================================================================ Question 19 (countPassing) Full credit needs: - Function signature matches: int countPassing(int grades[], int size) - A loop that visits every element (0 through size - 1, no off-by-one) - An if that tests grades[i] >= 60 (not > 60, which would miss exactly 60) - A counter that starts at 0, increases inside the if, and is returned Example: int countPassing(int grades[], int size) { int count = 0; for (int i = 0; i < size; i++) { if (grades[i] >= 60) { count++; } } return count; } Partial credit: correct loop and if, but the counter is never returned, or the boundary is > 60 instead of >= 60. No credit: no loop at all, hardcodes the size instead of using the parameter, or returns a grade instead of a count. Question 20 (toCelsius) Full credit needs: - Function signature matches: double toCelsius(double fahrenheit) - Returns (fahrenheit - 32) * 5 / 9 - Uses return, not cout, to give back the value Example: double toCelsius(double fahrenheit) { return (fahrenheit - 32) * 5 / 9; } Partial credit: right idea but writes (fahrenheit - 32) * (5 / 9), which is always 0 because 5 / 9 is integer division; or prints the result instead of returning it. No credit: wrong formula (e.g. adds 32 or divides by 5), or the function does not compile (wrong signature, missing return).