Computer Structure
A computer system is made up of several components. For National 5, you need to have an understanding of the purpose of and the workings of several of these components.
The Central Processing Unit
The Central Processing Unit or CPU is the part of a the computer that carries out (executes) the instructions passed to it.

A CPU
The CPU speaks to the other parts of the computer and makes the hardware and software work together.
Computers these days can carry out billions of instructions per second.
A processor is made up of several different components itself.
The ALU
The ALU or Arithmetic and Logic Unit is the part of the brain responsible for performing mathematics calculations and logical decisions within the computer system.
This means it carries out operations such as addition, subtraction, multiplication and division, but also
logical comparison such as comparing if one number is larger than another etc, and also making decisions
based on logical expressions such as those containing and
, or
and
not
.
The ALU is designed in a way that it works very fast to make a computer system responsive at all times.
The registers
The registers are a key part of the CPU that act as temporary memory locations. They are very small and only hold a couple of 1000 bytes of data.
Generally registers only store instructions and small amounts of data whilst the processor is working on them. To speed up a computer, the CPU also has a larger, yet slower temporary memory called cache memory.
The control unit
The control unit is the part of the computer which controls everything. The control unit sends out clock pulses that keep everything in sync (a clock pulse simply tells everything to work).
The control unit has a series of lines (wires) connected to it that allow the CPU to perform read and write operations from the RAM, reset the system and perform interrupts to the normal flow of a program (for example, PS/2 port mice interrupt the flow of the program when they are moved as the CPU has to deal with the mouse moving on the very microsecond it is moved).
RAM
RAM or Random Access Memory is a type of computer memory. It is volatile memory, meaning it is temporary.

Random Access Memory
The data stored in the memory is deleted when the program using it is closed. All data held in the memory is deleted when the computer is switched off.
Each piece of data held in the memory is given a unique address that the computer can easily retrieve. Each address can be accessed using the address bus using its unique ID.
SQA exam questions that come up normally look for you to state something about how each piece of data is given a unique address so make sure you remember to put something about that!
malloc
to allocate
memory to store data. This data can be directly retrieved using it's memory address in C, simply
by writing an asterisk in front of it, e.g. *98
. This is called a memory reference.
Buses
Computer systems join all the different parts together through different buses. For a long time, this was the front side bus, but it has since been replaced by PCI Express bus, the QuickPath Interconnect (QPI) bus, the Ultra Path Interconnect (UPI) bus, the Direct Media Interface (DMI) bus, the HyperTransport bus and and the Infinity Fabric bus.
These buses all do the same thing - they carry a bunch of instructions and interrupts between different components on the system. They do this using address lines, control lines, and data lines.
These lines make up three buses called the address bus, the data bus and the control bus.
Address Bus
The address bus holds the unique address in RAM when the processor is trying to access the RAM.
It is a unidirectional bus as it only send data from the process to the RAM.
Data Bus
The data bus carries data between the processor and the memory. It is a bidirectional bus as the processor transfers data to the RAM using it and the RAM transfers data to the processor using it.
Control Bus
The control bus is used to send control signals to different devices across the computer system.
Translator programs
Translator programs are an essential part of programming today.
Programming languages such as Python, Java, Visual Basic etc, all require translation that the programmer writes to something that the computer can understand.
A translator can turn code from a high-level language (the source code), that is, a language similar to English (such as Python or Java), into a low-level language, that is, a language a computer can understand.
The most common type of translator programs these days are ones that are transforming code from a high-level language to opcode or bytecode and then executing it, but there are still many compilers that translate the code directly into machine code (1s and 0s).
There are two types of translator programs you need to know about for National 5 Computing Science:
- Compilers
- Interpreters
Compilers
A compiler is a program that turns source code into object-code. A compiler is used to make code portable as, unlike an interpred program, it does not require additional software to run it.
One key difference between a compiler and an interpreter is in the way they deal with errors. A compiled program will crash when it finds unexpected code it will crash and display an error at the end.
Interpreters
An interpreter is a special piece of software that reads each line of code line-by-line and translates it to machine code.
By doing this line-by-line, it specify where the error is much more clearly than a compiler can.
Interpreted programs are slower than compiled programs and the interpreter program is required on the computer running the program to execute it.
Mr Balfour has created an SQA Reference Language compiler and runtime that you can download and actually find out how it works, too.
The Environmental Impact of Computers
Computer systems draw a lot of energy. According to statistics, as of 2024 there are around 2.2 billion computers in use in the world. If the average computer consumes around 70 watts of energy, we are looking 1.54 terawatts of energy being used by them every hour.
We need to think about steps to reduce the impact they are having on the environment by reducing their electricity draw.
Monitor settings
You can make changes to your monitor settings to reduce the amount of energy it consumes.
Some monitors support an eco mode which is designed to set the monitors settings to the best options for lower energy use. However, if it does not, these options can reduce the energy consumption of monitors:
- Reducing the brightness manually can be one of the best ways to reduce the energy consumption of monitors. Some monitors come with sensors that determines the best brightness for the room.
- Avoid screensavers and have the monitor switch to standby instead of this.
- Reduce the refresh rate of the monitor (the SQA does not list this one, but it is indeed a correct answer)
- Use energy efficient monitors (for example, an IPS display uses 2x as much energy as a TN display)
Power-down settings
Modern operating systems (from Windows XP+ and Mac OS X 10.1+) allow you to set specific settings to help reduce the amount of energy a computer uses by powering down devices when they are not in use.
The following is a list of actions that it can take to reduce power consumption:
- Put the monitor on to a lower power state
- Power the system down after a short period of time
- Put the CPU into a lower power state (S0 - S6 are power states in modern ACPI compliant POSIX operating systems)
- Slower mechanical hard drives use a lot of energy compared with modern solid state disks and therefore have settings to switch them to a lower power state
- Network adapters can also enter a low power state when they are not being used.
Remember, a lot of these settings need to be turned on first.
Standby settings
Standby or sleep mode is a mode that was designed to keep the computer system powered but in a very low power state. It does this by keeping the CPU running in state S0 - i.e. the lowest power mode it has and keeps the RAM with all the data in it powered. It then switches everything else (the graphics card, hard drives, monitors etc) off. When the user wishes to continue again, the CPU moves up power states gradually and then sends signals to the other devices to start up.
In standby, the RAM remains powered so that resuming use with the computer can be very quick.
Another mode that is common is hibernate. This mode is similar to standby but is considerably better at saving energy as it puts the computer to sleep. The main difference between these two modes is that in hibernate mode, the computer copies the contents of the RAM to the storage device (hard disk or solid state drive) of the computer and then switches off entirely. When the user wishes to resume working on their computer, the computer copies the data from the storage device back to RAM again. This is considerably slower than standby when starting up, but with modern NVMe storage, this is becoming less of an issue.
Security Precautions
Computer crime is a big threat to everyone today. There are certain precautions we can all take to ensure our data and information is safe.
Firewalls
A firewall is a special piece of hardware or software that can either be used to determine what is allowed in and out of a computer network or computer.
Firewalls contain a set of rules that determine what packets are allowed in or out.
The rules could state which ports or which IP addresses are allowed to send/receive data.
Encryption
Encryption is used to prevent unauthorised access to data during transmission over a network. Encryption played a heavy role in World War II where the Germans relied heavily on it to send and receive instructions.

Random Access Memory
Encryption scrambles the content of the data to ensure that the only way to unscramble it is to use the decryption algorithm.
In asymmetric encryption, the data is encrypted using a public key and decrypted using a combination of the public key and a private key. This is common across the Internet.
Caesar Cipher
A simple type of encryption is the Caesar Cipher.
In this type of cipher, every letter is 'shifted' along the alphabet. If a shift of 3 is given:
b → e
...
z → c
Data Representation
Computers are often referred to as two-state machines. This is down to the way in which they work underneath. The two states, 1 or 0, are known as binary.
Computers are made up of tiny switches known as transistors that can either on or off.
Converting from binary to decimal
Converting from binary to decimal is easy, simply put the place values at the top, doubling each time from the right, then write your binary number below it:
128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
---|---|---|---|---|---|---|---|
1 | 0 | 1 | 1 | 0 | 1 | 0 | 1 |
To get the denary number from this simply add all the place values with a 1 under them together.
128 + 32 + 16 + 4 + 1 = 181
Denary to binary
Once again, start by writing out the place values:
128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
---|
In this example, we are going to use the number 73.
Now look from left to right and find the first value that is less than the number you are looking for and put a 1 underneath it:
128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
---|---|---|---|---|---|---|---|
1 |
Next, put a 0 under any numbers left of this one.
128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
---|---|---|---|---|---|---|---|
0 | 1 |
Now repeat this process until you are at the very right hand side or all of the place values with a 1 under them add up to the number you are looking for.
128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
---|---|---|---|---|---|---|---|
0 | 1 | 0 | 0 | 1 | 0 | 0 | 1 |
Range of numbers representable
The range of numbers (i.e. the smallest and the largest numbers) representable by binary are defined by the number of bits allocated.
To quickly calculate the largest number, simply use the following formula:
$$max = 2^n - 1$$
Where n is the number of bits given.
An unsigned integer uses a 32-bit binary string to represent a number, meaning it can represent a range of numbers from 0 to 4,294,967,295.
Floating point represetnation
For National 5, you need to know that floating point representation is a system used by computers to store large numbers. It consists of a mantissa and exponent.
Floating point is similar to standard form. In standard form we can write the number 14.3 as:
$$\rlap{\overbrace{\phantom{0.143}}^{mantissa}}0.143\times10\underbrace{^{2}}_{exponent}$$
You can see that this is the same number and that the exponent of 2 is how many times the decimal place has moved to the right.
ASCII
ASCII or American Stanard Code for Information Interchange is a standardised format for representing characters and symbols on a computer system.
ASCII maps several numbers (which are represented as binary strings) to characters and symbols:
A | 65 |
---|---|
C | 67 |
! | 49 |
Use this input box to tell you what the ASCII number of a key press is on your device:
The original iteration of ASCII had 7 bits to represent characters and symbols and could therefore represent just 128 characters and symbols.
This became a problem quickly as there are definitely more than 128 symbols let alone characters on a standard computer. As a result, Extended ASCII was developed. Extended ASCII partly fixed this by giving 8 bits to each characters representation. This meant 256 characters or symbols could be represented.
Bitmap graphics
A bitmap is a 2D array of pixels. A bitmap can be seen as being analogous of a table of pixels.

The number of pixels going across (the width) multiplied by the number of pixels going up and down (the height) is called the resolution.
The bit depth is the number of bits required to store each pixel. Computers today use 24 bits per pixel, plus 8 bits for transparency. HDR (High Dynamic Range) displays and images use 40 bits per pixel including everything 32 bit has plus brightness to create a more immersive experience.
The higher the bit depth is, the more colours that can be represented by each pixel, and indeed the image.
Bit depth | Representable colours |
---|---|
8 bit | 28 = 256 |
16 bit | 216 = 65,536 |
24 bit | 224 = 16,777,216 |
32 bit | 232 = 4,294,967,296 |
40 bit | 240 = 1,099,511,627,776 |
Bitmap graphics are resolution dependent. This means when you resize them you'll lose quality.
The higher the resolution, the larger the file.
Vector graphics
Vector graphics work differently to bitmap graphics. Instead of storing data as pixels, they store a series of instructions that the computer must repaint each time it needs to display the graphic.
The instructions for SVG, for example, look very similar to HTML (that's because both SVG and HTML are dialects of XML):
Vector graphics are generally very small in size, even when the image itself is very big, but as you increase the number of objects in the graphic, the file size will increase due to the number of instructions in the graphic file increasing.
Vector graphic objects
There are four different objects you need to know about for National 5 Computing Science:
- Line
- Rectangle
- Ellipse
- Polygon
Line
A line, sometimes called a polyline is an object that simply connects two points together. Lines can be made complex by adding anchor points.
Rectangle
A rectangle object is simply a polygon with four points.
Ellipse
An ellipse is a curved object. An ellipse has a radius so that it can be made more or less curved.
In questions related to vector graphics and ellipses, do not answer with the words circle or oval.
Polygon
A polygon is any shape with at least three sides.
Vector graphic attributes
For National 5 you must be able to provide examples of different attributes that you might find on vector graphics.
- Co-ordinates (x coordinate and y coordinate)
- Fill colour
- Line colour