Chapter 3. Using Variables, Declaring Constants

Programs need a way to store the data they use or create so that it can be used later in the program’s execution. Variables and constants offer various ways to represent, store, and manipulate that data.

In this lesson, you will learn

  • How to declare and define variables and constants

  • How to assign values to variables and manipulate those values

  • How to write the value of a variable to the screen

What Is a Variable?

In C++, a variable is a place to store information. A variable is a location in your computer’s memory in which you can store a value and from which you can later retrieve that value.

Notice that variables are used for temporary storage. When you exit a program or turn the computer off, the information ...

Get Sams Teach Yourself C++ in One Hour a Day, Sixth Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.