C++20 sections · 1024 units
Open in Course

What is a Variable?

Containers for values

A variable is a named location in memory that holds a value. Think of it as a labeled box where you can store a number, letter, or other data. You give each variable a name so you can refer to it later.

When you write int score = 100;, you create a box labeled 'score' that holds the number 100. Variables let you reuse values without typing them repeatedly. If you need to use a player's score in ten places, you store it once and reference the variable name.