Variable Storage

When a variable is created, the value assigned to that variable needs to be stored somewhere. Different programming languages handle variable storage differently, but they all store the values somewhere in RAM. We discuss RAM in more detail in the next chapter, but for now, you can think of RAM like a really big blank book with numbered pages. When the value of a variable is stored in RAM, one or more pages are set aside for storing the value of that variable. The number of pages is based on how big the program thinks that value will be (more on this when we discuss data types in Chapter 5). Similar to the index at the back of a book, the program keeps a reference to where the value of each variable is stored. Updating the value ...

Get Learning to Program now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.