O'Reilly logo

Sams Teach Yourself C++ in 21 Days , Fifth Edition by Bradley Jones, Jesse Liberty

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required