GCSE (J277)
Linear Search and Index Match
A FOR loop checks each item of a 1D array against a target.
OCR Exam Reference Language
1names = ["Ali", "Beth", "Cara", "Dev"]◀ now2target = "Cara"3found = -14FOR i = 0 TO 35 IF names[i]! == target THEN6 found = i7 ENDIF8NEXT i9print(found)
Predict
Line 1Step 1 of 13
The array names is created with indexes 0 to 3
Nothing to predict here. Press Step and Predict to run this line.
OCR Trace Table0 rows
| Line | names | target | found | i | Condition | Output |
|---|---|---|---|---|---|---|
| Rows appear here as you solve each line. | ||||||