O'Reilly logo

C++ All-In-One For Dummies®, 2nd Edition by Jeff Cogswell, John Paul Mueller

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

Chapter 2. Storing Data in C++

In This Chapter

  • Using storage bins called variables

  • Working with integer variables

  • Using character variables

  • Manipulating strings

  • Using Boolean variables

  • Using conditional operators

  • Reading from the console

We all love to store things away. Our closets are a perfect example of a place to store things. We have boxes in there that we have not opened in years. Perhaps we inadvertently created a time capsule. Or just a fire hazard. When you program a computer, you can also store things away. Most people know that computers have two kinds of memory: memory inside the chips and memory in the hard drive. But most people use the term memory in reference to the memory chips; the other is just referred to as the hard drive. When you type a business letter in a word processor, the letter is stored in the memory. After you choose File

Storing Data in C++

The best way to think of memory is as a set of storage bins, much like the ones in the closet that we are afraid of. When you write a computer program, you reserve some storage bins, and you give each storage bin a name. You also say what type of thing can go inside the storage bin. The technical term for such a storage bin is a variable.

In this chapter, we show you how you can use these storage bins in your programs.

Tip

The programs in this and the remaining chapters work with the free compiler included on this book's CD-ROM. You can also use ...

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