© Will Briggs 2021
W. BriggsC++20 for Lazy Programmershttps://doi.org/10.1007/978-1-4842-6306-8_10

10. Arrays and enum

Will Briggs1  
Lynchburg, VA, USA

In this chapter are: sequences (arrays) of values, enumeration types, weather data, and board games.


“If you don’t like the weather in these parts,” the old-timer said with a twinkle in his eye, “wait a few minutes.”

Let’s find out if he’s right. We’ll take ten temperatures at one-minute intervals and see the variation. I’ll start like this:
double temp1; sout << "Enter a temperature: "; sin >> temp1;
double temp2; sout << "Enter a temperature: "; sin >> temp2;
double temp3; sout << "Enter a temperature: "; sin >> temp3;
That’s getting old fast. Maybe there’s a better way to store ten numbers. ...

Get C++20 for Lazy Programmers: Quick, Easy, and Fun C++ for Beginners now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.