Remember the list
type in Python?
cities = ["Calgary", "Vancouver", "Toronto"]
current_temp = [15, 18, 20]
It's possible, but not a good idea, to have mixed data types
city_and_current_temp = ["Calgary", 15]
Arrays in C++ are kind of like lists, but the data types must be the same
We'll start by looking at "C-style" arrays
data_type variable_name[array_size];
double current_temp[3];
[]
with the index starting at 0current_temp[0] = 15;
current_temp[1] = 18;
current_temp[2] = 20;
for (int i = 0; i < 3; i++) {
cout << "The current temperature is: " << current_temp[i] << endl;
}
double current_temp[3] = {15, 18, 20};
Textbook Chapter 7
Venn diagram time
Let them think for a bit while I work on solution
Does anyone remember why mixed types aren't a good idea?
Draw what's happening in memory