5 Arrays: We’ve Got Their Number

The last couple of chapters have had a theme: once you define a task (no matter how simple or how complex) you can ask the computer to perform it any number of times. We’ve seen this principle at work in while loops and for loops, as well as functions. It’s this fact—more than any other—that demonstrates the power of computer software.

But the magic of computers lies not just in the fact they can perform an arbitrarily large number of repetitions. They can also work on arbitrarily large amounts of data.

An “array” is an arbitrarily large collection of data indexed by number. With a few keystrokes—as you’ll see in this chapter—you can create array data structures of any size. Then, by using loops, you can process ...

Get C++ Without Fear: A Beginner’s Guide That Makes You Feel Smart 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.