Form 1 · Chapter 4

Coding

Coding turns an algorithm into instructions a computer can run. Learn about programs, variables, input, output and control structures.

From algorithm to program

Coding means writing instructions in a programming language so a computer can carry out a task. A finished set of instructions is called a program. Each line is an instruction that tells the computer to do one small thing, such as show a message or add two numbers. The computer follows the instructions in order, exactly as written.

Variables and data

A variable is a named box in memory that stores a value which can change while the program runs. For example, score might start at 0 and grow as you play. We put data into a program with input (from the keyboard) and show results with output (on the screen).

Key idea

A program uses input, process and output. It takes in data, works on it, and shows a result. Variables hold the data in between.

Control structures in code

Just like algorithms, programs use sequence, selection and loop. A common beginner tool is Scratch, which uses coloured blocks you drag and join, so you code without typing.

Example

A simple program:
INPUT name
OUTPUT "Hello " + name
Here name is a variable. The first line is input, the second is output.

Stuck on this topic? A verified JomKelas tutor can walk you through it.

Find a verified tutor