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

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