Established 2026  ·  Free Educational Resources for All

Computer & AI · Technology

How Computers Work: Hardware, Software and the Language of Binary

A computer follows very simple instructions, extremely fast. This guide builds the picture from tiny switches and logic gates to binary, the CPU's three-step loop, memory and software, with diagrams and worked examples you can do by hand.

EDUSAMBAM Editorial Team | 15 min read | Technology |Last updated: October 2026
🔊 LISTEN TO THIS ARTICLE
SAVE YOUR EYES • IMPROVE YOUR LISTENING
Listen to the article instead of relying only on continuous screen reading.
Ready to read the article.

A computer does not think or understand. It follows a huge number of very simple instructions, extremely fast and without ever getting tired or bored. Underneath every app, game and website sits the same short list of ideas: tiny electronic switches that are either on or off, simple logic built from those switches, numbers written with just two digits, a processor that repeats one three-step cycle billions of times a second, and memory that holds what it is working on. This guide builds the whole picture from the ground up, with worked examples you can do by hand, so that a computer stops feeling like magic.

1.What Is a Computer?

A computer is a machine that takes in information (input), follows instructions to process it, stores information, and produces a result (output). Under that broad definition, a calculator, a washing machine's control panel and a supercomputer all count. What makes a modern computer special is that it is programmable and general-purpose: the same physical machine can run a spreadsheet, play a video or control a robot, just by loading different instructions. That idea goes back to Charles Babbage's designs and Alan Turing's theory (see The History of Computing).

Input, processing, output and storage Input devices such as a keyboard, touchscreen, camera and microphone feed data to the processing part: the CPU and memory. The processing part sends results to output devices such as a screen and speakers. Storage connects both ways to processing, and software supplies the instructions. The basic shape of every computer Input keyboard, touchcamera, microphonesensors, network Processing CPU Memory (RAM) Output screen, speakersprinter, vibrationnetwork StorageSSD or hard drive Software = the instructions
Figure 1. Data flows from input, through processing, to output, with storage for what must be kept. Software gives the instructions. The dashed arrows move unless your device is set to reduce motion.

2.Switches and Logic: How Simple Parts Make Decisions

The basic building block of a modern computer is the transistor, a tiny electronic switch with no moving parts. It lets current flow or blocks it, depending on a control signal. A switch has two reliable states, on and off, which we write as 1 and 0. A modern processor contains billions of transistors.

Combining a few transistors makes a logic gate, a circuit that takes one or more 1/0 inputs and gives a single 1/0 output according to a rule:

GateRuleOutput is 1 when...
NOTFlips the inputthe input is 0
ANDBoth inputs must be 1A is 1 and B is 1
ORAt least one input is 1A is 1 or B is 1 (or both)
XORExactly one input is 1A and B are different

It may seem impossible that such simple rules could add numbers, show video or run a game. But gates can be wired together, and wired-together gates can do arithmetic, compare values and remember information. Everything a computer does is built in layers on top of these simple rules.

A half adder made from an XOR gate and an AND gate Two inputs, A and B, each connect to both an XOR gate and an AND gate. The XOR gate gives the sum bit. The AND gate gives the carry bit. With A and B both 1, the sum is 0 and the carry is 1, which together make binary 10, the number two. Adding two bits with two gates XOR AND A=1 B=1 Sum = 0(different? no) Carry = 1(both are 1? yes) 1 + 1 = binary 10 (carry 1, sum 0) Signals flow left to right unless your device is set to reduce motion.
Figure 2. A half adder. It adds two single bits using one XOR gate (for the sum) and one AND gate (for the carry). Chains of these circuits add whole numbers.
Worked Example 1: Adding two bits with gates

A half adder adds two single bits, A and B. It has two outputs: Sum = A XOR B, and Carry = A AND B.

ABSum (XOR)Carry (AND)Result
000000 = 0
011001 = 1
101001 = 1
110110 = 2

Check the last row: 1 + 1 = 2. In binary, two is written 10 (one two, no ones). The sum bit is 0 and the carry bit is 1, exactly as in decimal when 5 + 5 gives 0 and carries 1.

Going further: to add longer numbers, a full adder also accepts a carry from the previous column. A row of full adders adds numbers of any size. So arithmetic, the heart of a computer, is nothing more than gates arranged cleverly.

3.Binary: Writing Everything With Two Digits

Because the hardware has two states, computers store everything with binary (base 2). Each 0 or 1 is a bit (binary digit). Eight bits make a byte. Place values double as you move left, in the same way decimal place values multiply by ten: 1, 2, 4, 8, 16, 32, 64, 128 and so on. An n-bit number can take 2n different values, so 8 bits give 28 = 256 values (0 to 255).

Worked Example 2: Converting between decimal and binary

Decimal 45 to binary. Write the 8 place values: 128, 64, 32, 16, 8, 4, 2, 1.

Reading the digits from left to right: 00101101. Check: 32 + 8 + 4 + 1 = 45. ✓

Binary 01100100 to decimal. Add the place values wherever there is a 1: 64 + 32 + 4 = 100.

A limit to know: the biggest 8-bit number is 11111111 = 255. Adding 1 needs a ninth bit. If only 8 bits are kept, the result wraps round to 00000000. This is called overflow, and it is the reason programs choose number sizes carefully.

4.How Bits Become Text, Pictures and Sound

Bits have no meaning on their own. Meaning comes from an agreed way of reading them:

A tiny picture stored as bits A five by five grid of pixels forming a heart. Dark cells are 1 and light cells are 0. The five rows read 01010, 11111, 11111, 01110 and 00100, which are the decimal numbers 10, 31, 31, 14 and 4. A picture is a grid of numbers 0101011111111110111000100 01010 = 1011111 = 3111111 = 3101110 = 1400100 = 4 Dark pixel = 1 Light pixel = 0 Stored as: 10, 31, 31, 14, 4
Figure 3. A tiny black-and-white picture. Each row of five pixels is a 5-bit number. The whole picture is just five numbers.
Worked Example 3: How big are pictures and sound?

Colours: with 3 bytes (24 bits) per pixel, the number of possible colours is 224 = 16,777,216.

A photo: a full-HD image is 1,920 × 1,080 pixels = 2,073,600 pixels. At 3 bytes each: 2,073,600 × 3 = 6,220,800 bytes, which is about 6.2 MB if stored with no compression.

A song: CD-quality sound takes 44,100 samples per second, each of 2 bytes (16 bits), on 2 channels (stereo). Bytes per second: 44,100 × 2 × 2 = 176,400. For a 3-minute song (180 seconds): 176,400 × 180 = 31,752,000 bytes, about 31.8 MB.

Why files are usually smaller: compression, as used by JPEG images and MP3 or AAC audio, removes repeated or less noticeable detail, so real files are often many times smaller than these raw figures.

A note on units: in storage, 1 kilobyte is usually 1,000 bytes and 1 megabyte is 1,000,000 bytes. Some software instead counts in units of 1,024, which is why the same drive can show slightly different sizes.

5.The Core Hardware

The physical parts are called hardware. Four do most of the work, and the rest connect them:

Memory typeSpeedSize (typical)Keeps data when off?
CPU registers and cacheFastestTiny (bytes to megabytes)No
RAMVery fastGigabytesNo
SSDFastHundreds of gigabytes to terabytesYes
Hard diskSlowerTerabytesYes

This pattern is called a memory hierarchy: the faster the memory, the smaller and more expensive it is. Computers keep what they need most right now in the fast, small levels and the rest in the slow, large levels.

6.The CPU's Three-Step Loop

Whatever a program does, the CPU repeats the same loop, called the fetch-decode-execute cycle:

  1. Fetch: get the next instruction from memory. A small register called the program counter holds the address of the next instruction.
  2. Decode: work out what the instruction means, for example "add" or "store".
  3. Execute: carry it out, then move the program counter on to the next instruction.
The fetch, decode, execute cycle Three steps in a loop: fetch the next instruction from memory, decode it to see what it means, and execute it. Then the loop starts again with the next instruction. The loop at the heart of every CPU 1. Fetchnext instruction 2. Decodewhat it means 3. Executedo it, repeat Billions ofloops a second The highlight moves around the loop unless your device is set to reduce motion.
Figure 4. Fetch, decode, execute, repeat. Real processors overlap these steps for many instructions at once, but the idea is the same.
Worked Example 4: Tracing a tiny program

Imagine a very simple processor with one working register called A, and this four-instruction program stored in memory:

  1. LOAD 5 puts the number 5 into A.
  2. ADD 3 adds 3 to A.
  3. STORE 7 copies A into memory location 7.
  4. HALT stops.
After instructionRegister AMemory location 7
(start)00
LOAD 550
ADD 380
STORE 788

Result: location 7 now holds 8, which is 5 + 3.

How long would it take? Three instructions with 3 steps each (fetch, decode, execute) is 9 steps. If each step took one tick of a 3 GHz clock (3,000,000,000 ticks per second), each tick lasts 1 ÷ 3,000,000,000 ≈ 0.33 nanoseconds, so 9 ticks ≈ 3 nanoseconds. That is an idealised figure, since real instructions often take more ticks, but it shows how enormous the speed is.

A neat consequence: light travels about 30 cm in a nanosecond, so in one tick of a 3 GHz clock it moves only about 10 cm. Signals cannot cross a large chip instantly, which is one reason processors are built small.

7.Software: The Instructions

Software is the set of instructions that tells hardware what to do. There are layers of it:

The processor can only run its own machine code, which is a list of binary instructions specific to that type of CPU. People rarely write that directly. They write in a programming language such as Python or JavaScript, which is much closer to human language. A compiler translates the whole program into machine code in advance, while an interpreter translates and runs it step by step. See What Is Coding? for more.

8.Putting It Together: From a Key Press to the Screen

Watch what happens when you press the letter "A" while typing a message:

  1. The keyboard detects the key and sends a signal that is a number identifying it.
  2. The signal reaches the computer, which interrupts what the CPU is doing so the operating system can read it.
  3. The operating system passes the key to the program that is in focus, such as your message app.
  4. The app runs instructions that store the character in RAM and update the text.
  5. The graphics hardware draws the new text as pixels, and the screen lights up the right dots.

All of that takes a few thousandths of a second, so it feels instant. At no point does anything in the machine "know" what the letter means. Each step simply moves numbers and applies rules.

9.Computers Everywhere

Most computers do not look like computers. Chips called microcontrollers sit inside washing machines, cars, thermostats and toys, running one fixed program. Phones and laptops are general-purpose computers. Servers in data centres answer requests from many users (see Cloud Computing), and supercomputers link enormous numbers of processors to tackle scientific problems such as weather forecasting. They differ in size, power and purpose, but the same ideas run through them all: bits, gates, a processor looping through instructions, and memory.

10.Common Mistakes and Misconceptions

11.Check Your Understanding

Try each question first, then tap it to reveal the answer. A scored multiple-choice quiz follows below.

1. What is the difference between a bit and a byte?

A bit is a single 0 or 1. A byte is a group of 8 bits.

2. What does an AND gate output when its inputs are 1 and 0?

0, because AND gives 1 only when both inputs are 1.

3. Convert decimal 20 to 8-bit binary.

16 + 4 = 20, so the bits are 00010100.

4. A 1,000 × 1,000 pixel image uses 3 bytes per pixel with no compression. How big is it?

1,000 × 1,000 = 1,000,000 pixels. 1,000,000 × 3 = 3,000,000 bytes, about 3 MB.

5. Why is data in RAM lost when the power goes off, while data on an SSD is kept?

RAM needs a constant electrical supply to hold its contents (it is volatile). An SSD uses flash memory that keeps its stored state without power.

6. List the three steps of the CPU cycle in order.

Fetch the instruction, decode it, execute it. Then the cycle repeats.

12.Summary

For Teachers and Parents

Human logic gates: let two students hold up cards showing 0 or 1 as inputs, and a third student acts as an AND, OR or XOR gate, announcing the output. Chain two gates to make a half adder, as in Worked Example 1.

Binary bracelet: students write their initials in ASCII binary (A = 01000001) and make a bracelet using two bead colours for 0 and 1.

Pixel art: on squared paper, students draw a small picture, write each row as a binary number, and swap the numbers with a partner to rebuild each other's picture, as in Figure 3.

Be the CPU: give a student a card-based program like Worked Example 4 and a "register" whiteboard, and let them carry out fetch, decode and execute out loud.

Safety note: take care when opening computers. Unplug and ask an adult before opening one, and do not touch the power supply. Old devices should be recycled responsibly.

13.Sources and Further Reading

This article is original EDUSAMBAM writing. It follows the standard layered view of computer systems taught in university courses, and the numbers in the worked examples are plain arithmetic. All diagrams are original EDUSAMBAM schematics, and the tiny processor in Worked Example 4 is an invented teaching model, not a real instruction set.

Hardware changes quickly, so check current specifications for any device you are considering. This article does not recommend any particular brand or product.

Test Your Understanding

Practice Quiz

10 questions. Select an answer for each, then submit to see your score instantly.

0 of 10 answered
0/10
You scored 0%
Keep practicing
1.What is a byte?
2.What does an AND gate output when its inputs are 1 and 0?
3.In the half adder, what are the Sum and Carry for 1 + 1?
4.What is decimal 45 in 8-bit binary?
5.In ASCII, the capital letter A is 65. What is that in binary?
6.About how big is an uncompressed 1,920 x 1,080 image using 3 bytes per pixel?
7.What is the main difference between RAM and storage?
8.What are the three steps of the CPU cycle, in order?
9.Why does a higher GHz not always mean a faster computer?
10.What does a compiler do?
← Gateway Next: What Is the Internet, Really? →