Consider the following pseudocode. What does total represent after the algorithm finishes?
total = 0
FOR each package in shipment
IF package weight is greater than 10 THEN
total = total + package weight
END IF
END FOR
10, so total accumulates just those weights.
Explanation
A loop may run once for each item in a group, and a selection inside the loop may decide what to do with that item. Here the selection decides whether a package weight joins the running sum, so lighter packages leave total unchanged.
- A is not correct: the algorithm adds package weights rather than counting packages, so
totalnever records how many packages the shipment holds. - C is not correct: the running sum keeps every qualifying weight, so several heavy packages can contribute together; nothing in the algorithm compares one weight against another.
- D is not correct: packages whose weight is not greater than
10fail the condition, and a branch whose condition is not satisfied does not run.