Please enable JavaScript to use CodeHS

Want to receive Question of the Day updates? Subscribe Here

AP CSP Question of the Day Jan. 24, 2025

Reference
  1. Incorrect Correct No Answer was selected Invalid Answer

    Compare code segment 1 and 2 that are designed to produce the same results.
    Segment 1:

    sum ? 0
    FOR EACH num IN numList
    {
        sum ? sum + num
    }
    DISPLAY (sum)

    Segment 2:

    sum ? 0
    i ? 0
    REPEAT LENGTH(numList) - 1 TIMES
    {
        sum ? sum + numList[i+1]
        i ? i + 1
    }
    DISPLAY (sum)

    Which of the following statements is true?