Mixed algorithms
Answers are for parents and teachers.
1
10 numbers are input. Write in words an algorithm for the mean of those greater than 10 (if there are none, output “none”).
Start; S = 0, K = 0; for i from 1 to 10: input x; if x > 10 then S = S + x and K = K + 1; if K > 0 output S / K, otherwise output “none”; end.
2
The air temperature for the 7 days of a week is input. Write an algorithm that counts the days hotter than 30 °C.
K = 0; for i from 1 to 7: input t; if t > 30 then K = K + 1; output K.
3
Solve the equation x² – 6x + 5 = 0.
D = 36 – 20 = 16; x = (6 ± 4) / 2: 5 and 1.
4
Find the GCD of 90 and 24 with Euclid’s algorithm (subtraction).
6