1Medium
0/3

State what should be written in place of the labels L1 to L3 in the algorithm below to make it function correctly.

SUBROUTINE findHighestStock(searchMode, totalItems)
    inventory ← [['Espresso', 'Latte', 'Chai', 'Mocha', 'Tea'],
                 ['12', '45', '22', '8', '31']]
    pos ← 0
    maxStock ← -1
    IF searchMode = 'MAX' THEN
        FOR i ← 0 TO totalItems - 1
            quantity ← STRING_TO_INT(inventory[L1][i])
            IF quantity > maxStock THEN
                maxStock ← quantity
                pos ← L2
            ENDIF
        ENDFOR
    ELSE
        OUTPUT 'Feature coming soon'
    ENDIF
    IF maxStock ≠ -1 THEN
        OUTPUT inventory[0][pos], ' has stock of ', inventory[1][pos]
    ENDIF
ENDSUBROUTINE

OUTPUT 'Enter search mode (MAX or MIN): '
searchMode ← USERINPUT
findHighestStock(L3, 5)

L1:

L2:

L3:

[3]

Structured programming and subroutines (procedures and functions) Questions

Practise AQA GCSE Computer Science Structured programming and subroutines (procedures and functions) with exam-style questions for GCSE Computer Science. 100 questions, matched to the AQA GCSE Computer Science (8525) specification and written in Paper 1 and Paper 2 style. Every question includes a full worked solution and mark scheme, so you can see where marks are awarded rather than just whether you got the answer right.

Next

Structured programming and subroutines (procedures and functions) Questions

  1. GCSE
  2. /Computer Science
  3. /Structured programming and subroutines (procedures and functions)