Programming is writing instructions that a computer can carry out. This topic covers the building blocks found in every language. Variables and constants store data of a type such as integer, real, string or Boolean. Sequence, selection and iteration control the order of steps: IF statements choose, and FOR, WHILE and REPEAT loops repeat. Arrays hold lists of values, and procedures and functions break a long program into parts. Programs also validate input, handle strings and read and write files. You practise these in pseudocode and in Python.
>= in its test.
DECLARE Height : ARRAY[1:5] OF INTEGER
DECLARE Child : INTEGER
DECLARE Tallest : INTEGER
Height[1] ← 5
Height[2] ← 9
Height[3] ← 3
Height[4] ← 9
Height[5] ← 1
Tallest ← 1
FOR Child ← 2 TO 5
IF Height[Child] >= Height[Tallest]
THEN
Tallest ← Child
ENDIF
NEXT Child
OUTPUT Tallest
What is output?>=, the last of two equal largest values wins.
2 would be right with >. 9 is the value, not the position. 5 is the last index, but 1 is not at least 9.Log in to join the discussion.
Loading…