Computer Science Fundamentals from Scratch

How Computers Work: CPU, Memory and Storage

Lesson 1 of 5 2 min read Updated 28 September 2026

The big picture

A computer takes input, processes it and produces output, and can store data along the way. Everything from a calculator to a smartphone follows this pattern.

The main components

  • CPU (Central Processing Unit): executes instructions. Modern CPUs have several cores, each able to work on a task.
  • Memory (RAM): fast, temporary storage that holds data and programs currently in use.
  • Storage (SSD or HDD): slower, permanent storage.
  • Input devices: keyboard, mouse, touch screen, microphone.
  • Output devices: screen, speakers, printer.
  • Buses: pathways that carry data between components.

The fetch-decode-execute cycle

The CPU repeats three steps billions of times per second:

  1. Fetch the next instruction from memory.
  2. Decode it to see what it means.
  3. Execute it, for example add two numbers.

The memory hierarchy

Faster memory is smaller and costs more.

LevelSpeedSize
CPU registers and cacheFastestKilobytes to megabytes
RAMFastGigabytes
SSD / HDDSlowerHundreds of gigabytes to terabytes

From your code to the CPU

A program written in a language such as Python or C is translated to machine code, which is binary. The operating system loads it into RAM, and the CPU runs it. Compilers translate code before running, and interpreters translate as it runs.

Why this matters for programmers

  • Programs slow down if they use too much memory.
  • Reading from disk is far slower than reading from RAM.
  • More cores help only if the program can do work in parallel.

Practice

Look at your computer's Task Manager or Activity Monitor and identify how much CPU and RAM your browser uses.