COMP-051: Mock Midterm 4, Modules 1-6 Matches: Midterm4-Modules1-6.txt (questions), 5 points each, 100 total. ================================================================ PART 1: MULTIPLE CHOICE ANSWERS ================================================================ 1. A 10. B 2. B 11. C 3. C 12. D 4. D 13. A 5. A 14. B 6. B 15. C 7. C 16. D 8. D 17. A 9. A 18. B ================================================================ PART 2: WRITE THE FUNCTION, GRADING GUIDE ================================================================ Question 19 (square) Full credit needs: - Function signature matches: int square(int n) - Returns n * n (or n multiplied by itself), not n + n or 2 * n - Uses return, not cout, to give back the value Example: int square(int n) { return n * n; } Partial credit: correct logic but wrong signature (missing int types, wrong parameter name is fine), or prints instead of returning. No credit: does not multiply n by itself, or the function does not compile as a real function (e.g. just a loose expression). Question 20 (isEven) Full credit needs: - Function signature matches: bool isEven(int n) - Uses n % 2 == 0 to test evenness - Returns true or false, not 1/0 printed with cout Example: bool isEven(int n) { return n % 2 == 0; } Partial credit: correct modulo logic but wrong return type (e.g. returns int 1/0 instead of bool true/false), or prints the result instead of returning it. No credit: does not use modulo (%) at all, or checks the wrong condition (e.g. n % 2 == 1 labeled as isEven).