O'Reilly logo

SAMS Teach Yourself C++ in 10 Minutes SECOND EDITION by 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

Using an Array to Create a Calculator Tape

The calculator program will make use of an array to keep track of what has been entered so far. You'll use it to create a “calculator tape,” with an entry for each operator/operand pair entered.

An array is a named sequence of locations for data. Each location is called an element and each element holds the same type of data. You use an element by specifying the name of the array and an index that is the numeric offset of the element in the array; this starts at zero.

You define an array by identifying the type of data it will hold in each element, followed by the array name and the count of elements it will contain, in brackets—for instance, int SomeArray[3]. The count can be any literal, constant, ...

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