Caffeinated Coder
Book an appointment
Lesson 03 · Basics

Variables and types

A C++ variable is a named box in memory, and its type is fixed when you declare it. Follow six short lines, then one bad one, as each declaration makes a box exactly as big as its type (int 4 bytes, double 8, char and bool 1), values move in and change, 7 / 2 turns out to be 3, and the compiler refuses to put text into an int before the program can run.

10 min9 steps6 questionsBeginner
Fig 3 · Interactive
Loading figure…
or ← →

Quiz Unlocks after the last step.