Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.
Shade in the A or B circle for each question.
Draw a line connecting each item on the left to its match on the right.
| Left column | Right column | |
|---|---|---|
| 1Found ← FALSE | ADECLARE Found : BOOLEAN | |
| 2IF Names[Index] = Target THEN Found ← TRUE | BCompares the current array element with the target and sets the flag to TRUE if they are equal | |
| 3Declare a BOOLEAN variable to hold whether the target was found | CThe output line assigns TRUE to Found instead of reporting the result, so it always shows a match. It should output Found or a message based on its value. | |
| 4After the loop ends, output a message only if the flag shows the target was seen | DIF Found = TRUE THEN OUTPUT "Found" ELSE OUTPUT "Not found" ENDIF | |
| 5FOR Index ← 1 TO 5 Found ← FALSE IF Names[Index] = Target THEN Found ← TRUE NEXT Index | ESets the flag to FALSE before the loop starts, meaning the target has not been seen yet | |
| 6FOR Index ← 1 TO 5 IF Names[Index] = Target THEN Found ← TRUE NEXT Index OUTPUT Found ← TRUE | FFound ← FALSE is inside the loop, so it resets the flag on every pass and a match can be lost. It must be set once before the loop. |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
Found ← FALSE — Sets a BOOLEAN flag to FALSE before a FOR loop. The loop sets Found to TRUE if an element equals the target. After the loop, Found shows whether the target was seen.DECLARE Found : BOOLEAN
DECLARE Index : INTEGERFound ← FALSE
FOR Index ← 1 TO 5
IF Names[Index] = Target THENFOR Index ← 1 TO 5
IF Names[Index] = Target THEN
Found ← TRUEIF Names[Index] = Target THEN
Found ← TRUE
ENDIFNEXT Index
IF Found = TRUE THEN
OUTPUT "Name found"