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.
Temp keeps 15. Jar[1] takes 25. Jar[3] takes the 15 kept in Temp. Jar[2] does not change.
15 40 25 is the array before the swap. 25 40 25 forgets to use Temp. 40 25 15 moves the middle element too.Log in to join the discussion.
Loading…