Day 3. Working with Variables and Constants

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

Today, 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 21 Days , Fifth Edition 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.