Computer Science K to 12
Question 3 of 30
Competency 1—Knowledge of computational thinking and problem solving
DIRECTIONS: Read the question and select the best response.
The pseudocode below prompts the user to enter data from the keyboard one number at a time. Given the keyboard inputs 2, 5, 4, 5, and 4 in that order, what is the correct output of the following algorithm?
sum = 0
i = 0
while (i < 5) do {
print "Input a number, n"
input n
if (n mod 2 is equal to 0) then sum = sum + n
i = i + 1
} endwhile
avg_total = sum / i
output avg_total
- Enter to expand or collapse answer.Answer expanded
- Correct Response: A.
