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

Get C++ All-In-One For Dummies®, 2nd 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.