Identifying and Correcting Errors FRQ Practice

Responses receive AI feedback against a rubric after submission. Scores are practice estimates.

Question 1 of 5

A student's loop should DISPLAY numbers 1 through 5 but shows 1 through 4.

(a) Give a plausible off-by-one cause in a REPEAT UNTIL condition.

(b) Provide a corrected UNTIL condition assuming i starts at 1 and increments each time.

(c) List the expected outputs after the fix.

Question 2 of 5

Consider:

PROCEDURE MaxOfTwo(a, b)
{
    IF a > b
    {
        RETURN a
    }
    ELSE
    {
        RETURN a
    }
}

(a) Trace MaxOfTwo(3, 8) and MaxOfTwo(8, 3).

(b) Identify the error.

(c) Write a corrected ELSE body.

Question 3 of 5

Explain the difference between finding an error and correcting an error, using a wrong robot rotation as the example.

Question 4 of 5

Design a minimal test suite for a procedure that returns whether a classroom code is valid: length exactly 4 and first character is "C" (1-based indexing; assume a CHAR_AT(str, i) operation defined in the stem as returning the character at position i).

(a) List four test inputs and expected booleans.

(b) Explain which of your cases targets a boundary.

Question 5 of 5

A game stores health as an integer. Taking damage does health ← health - dmg without checks. A bug report says health became a large positive after a huge hit when using 8-bit unsigned storage.

(a) Explain how overflow could produce a large positive.

(b) Propose corrected logic that keeps health at minimum 0.

(c) Give one test case with starting health, dmg, and expected result.