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.
N goes 80, 40, 20, 10, 5, 2, 1. That is six passes. When N is 1, the condition N > 1 is FALSE and the loop stops.
5 stops at 2. 7 counts one pass too many. 40 is the value of N after the first pass, not the count.Log in to join the discussion.
Loading…