The big idea behind arrays is that arrays let us efficiently store multiple values in a single variable. What can we store in arrays? We can store anything, but each array can only store one data type. We can have an array of ints and we can have an another way of actors, but we can't mix ints and actors in a single array. This is a conceptual representation of what an array looks like. Typically, we will declare an array as a variable, and I have declared that this array as a variable named Gpas. Now, each of those boxes that contain the 0.0 is actually a location in memory. The separate things that are stored in those locations in memory have a specific name and that name is element, so we talk about the elements of the array as the content of the array. In this particular array, we have elements that are numbered zero through nine, and we'll talk in a couple of lectures about why we start at zero. But those numbers on the left-hand side give us a way of indicating which element we want to do something with. We might want to find out its value, we might want to put a value into it. But we need a way to say within this Gpas variable of 10 elements, which element we want to do something with? The number that we use to access a particular element in the array is called an index. We'll start by declaring our array variable, and the first thing we put is the datatype for each of the elements in the array. Then we put the name of the variable and I'm going to store some test scores in this variable, and this all looks just like the variable declarations we've had so far. The way we tell the compiler that we're going to actually have an array here is we put square brackets and we also put how many elements we're going to have in the array. Once we've declared an array, we can't change the size of the array. The way we actually access elements in the array is we put the array name, and then we use square brackets, and we provide the index of the element we want to manipulate, and then we can do something like set the scores 0-100. We start our indexing at zero, remember, and we can do this as well and so on. But this doesn't really actually harness the power of the array so much, because if we just do a line of code for each element and so on, this is going to be pretty awkward, especially for larger arrays. One of the great things about arrays is we can actually walk the array or touch each element of the array using a for loop. I'm going to comment this out, and instead of doing it that way, I'm going to use a for loop. We're going to start our loop control variable at zero. We're going to run our loop control variable up to but not including five because remember our elements are numbered 0, 1, 2, 3, and 4 for this particular array, and we'll increment i each time through the loop. I'm going to use this for loop to read in the scores, and what I'll put in the body of the loop is our typical input validation code. I'll go do that and then we'll come back and talk some more. Here we are. We're going to prompt for and get a score, and I've done a couple of things differently from what we've done before. I'm telling the user which score they're entering, and I'm using i plus 1 because the users are human and not a C++ program. Humans start counting at one, so we'll be asking for test scores one through five, but we'll be putting them at element zero through four. The other differences here where I'm reading into a particular element of the scores array. We saw up here that I can use literals to access particular elements of the array, but I can also use variables because variables hold a value and that value will be the index we use for the element in our array. The rest of this is what we've seen before. Of course, checking for invalid particular element that we've just read into rather than just a single variable like we've done previously. Let's run this code and I'll show you that the input validation loop works properly, and then I'll just enter some scores like so. That's how we can use a for loop to actually populate the array. Let's print out those scores to make sure we actually populated the array properly. You might think that you can do something like this. This will certainly compile. But when we run it, you'll see that you actually do not get the elements of the array there. We're actually looking at the memory address of where the scores array is stored, so that's not really what we wanted to do. We can't just print out the array all at once, we actually need to use a for loop to print out each element of the array. I know I'm going to want a line break before I do this. Now we need a for loop again, and of course we want to print out scores i. There we go. Now I will point out that we've been hard-coding the size of the array in these for loop, and we'll actually learn a better way to do that but not in this lecture, because this lecture was to give you your first introduction to how arrays work in C++. To recap, arrays, let us store multiple values in a single variable but we know those values have to all be the same datatype. We also learned that once we create an array, we can't change the size of the array, and I will comment that I inadvertently started some of my variable names with lowercase letters in the videos, but I'll fix that in the code that I'm providing to you.