ExamBank Scot · N5 Computing Science question bank · All N5 Computing Science questions
3 marks · Testing
State the type of error in the code above and how it can be corrected. Type of error Correction State the part of the processor used to compare stone_A_distance to stone_B_distance. Curling is a sport where stones are thrown down a lane of ice towards a target. In the example below, stone B is closest to the middle of the target and is the winner. stone A stone B A computer program calculates the distance of each stone from the middle of the target. The code below has been written to identify the winning stone but produces the wrong output. … Line 20 IF stone_A_distance < stone_B_distance THEN Line 21 SEND "Stone B is the winner." TO DISPLAY Line 22 ELSE Line 23 SEND "Stone A is the winner." TO DISPLAY Line 24 END IF …
One mark each for: • type logic • fix - change < to > - swap lines 21 and 23 Allow “swap output messages” ALU Arithmetic Logic Unit