COMP-051: Mock Midterm -- Modules 1-6 Matches: Midterm-Modules1-6.txt (questions), 5 points each, 100 total. ================================================================ PART 1: MULTIPLE CHOICE ANSWERS ================================================================ 1. A 10. A 2. A 11. B 3. C 12. B 4. A 13. A 5. B 14. C 6. C 15. C 7. A 16. A 8. B 17. A 9. C 18. B ================================================================ PART 2: FUNCTION IMPLEMENTATION -- GRADING GUIDES ================================================================ 19. average(int scores[], int size) -- sample correct answer: double average(int scores[], int size) { int sum = 0; for (int i = 0; i < size; i++) { sum += scores[i]; } return (double)sum / size; } Full credit needs: a loop that visits every element (0 through size - 1, no off-by-one), an accumulator summing the values, and a return of sum / size. The division must produce a double (cast sum, or declare sum as a double) -- plain int/int division silently truncates, which is a real, previously-documented pitfall for this exact kind of average calculation. Partial credit for a correct loop/sum with the int-division bug (no cast, so the average truncates to a whole number). No credit for hardcoding size instead of using the parameter, or for a function that doesn't compile (wrong signature, missing return). 20. isPassing(int grade) -- sample correct answer: bool isPassing(int grade) { if (grade >= 60) { return true; } return false; } (A one-line `return grade >= 60;` is equally correct and still satisfies "uses an if condition" in spirit for grading purposes, but the explicit if/else form above is the expected default.) Full credit needs: a correctly-bounded comparison (>= 60, not > 60 or > 59, which would misclassify a grade of exactly 60), and a genuine bool return in both branches. Partial credit for an off-by-one boundary (e.g. > 60 instead of >= 60). No credit for a function that returns an int/string instead of bool, or that never actually returns a value on one of the two paths.