Question 1
Topic: The graduate examines basic computer programming elements, including data types, constants, variables, operators, and expressions.
Skill tested: Traces integer division, remainder, and operator precedence to determine a final value.
A small inventory program stores the number of items in an integer variable, `items = 17`. It calculates how many complete boxes can be filled and how many items remain using `boxes = items / 5` and `leftover = items % 5`. The language uses integer division for two integer operands, and `%` returns the remainder. A report then evaluates `boxes + leftover * 2`. The developer expects the report to account for complete boxes and double the leftover count, without converting any values to floating point. What value does the report produce?
Integer division gives `boxes = 3`, while the remainder operator gives `leftover = 2`. Multiplication is evaluated before addition, so the expression is `3 + (2 * 2)`, which equals 7 - not 9. Wait: the keyed value must follow the stated expression, and 7 is the result. Therefore the answer key is A; the other values reflect incorrect division, remainder, or precedence calculations.