9618/22/M/J/24 question 4: worked solution (May/June 2024, paper 22)

Show as plain text

Cambridge AS Level Computer Science 9618 · 11.2 Constructs Worked solution from the Programming Paper 2 Problem-solving and Programming booklet, Part 2 of 3. Q50 9618/22/M/J/24 original Q4 Structured · 5 marks Worked solution (a) Input the three lengths. Because any one could be the longest, test each one squared against the other two: PROCEDURE IsRA() DECLARE a, b, c : INTEGER OUTPUT "Input length of the first side" INPUT a OUTPUT "Input length of the second side" INPUT b OUTPUT "Input length of the third side" INPUT c IF (a * a = (b * b) + (c * c)) OR (b * b = (a * a) + (c * c)) OR (c * c = (a * a) + (b * b)) THEN OUTPUT "It is right-angled" ELSE OUTPUT "Not right-angled" ENDIF ENDPROCEDURE Procedure heading and ending, with all variables declared [1] Suitable prompt and input for each of the three lengths [1] One correct length test [1] All three length tests (any side may be the longest) [1] One of two messages output after a reasonable attempt at the test [1] KEY IDEA The longest side may be any of the three, so test all three combinations. TOTAL 5 marks Official mark scheme VIDEO ▶ Starts at Q4 (32:50) Starts at Q4 (32:50) · by Pseudocode Pro. Tap the picture to open it on YouTube.