We've learned before that arrays are a contiguous sequence of single variables.
These arrays are called one dimensional arrays.
You can have more than one dimension.
And let's say we wanted a two dimensional array type Gerais just call and entry to the.
And just like for we have the size and we have another size.
So this theory actually has 100 elements so there are 10 rows in 10 columns.
The first 10 represents the number of rows and the next is the number of columns.
So for each row there are 10 columns.
Think of it that way.
This is effectively a grid of of in this case integers that can be set that can have values k just like
the one dimensional counterparts.
It's also contiguous in memory.
Here's my mental model for two D-Rays this here
the indices start at the top left and go from right to left in the columns and from top to bottom for
the rows just notice like one dimensional array is that indices start at zero.
And so array that's it Ray to d of 0 0 is the very top top left element and say
re to d of 0 1
would be the top middle element in this example.
And Ray we have two one would be the bottom middle in this example really two dimensional array is working
the same as one dimensional arrays just in two directions.
The indices go from zero to rolling minus one for rows and zero to column length minus one for columns.
So here's how you would initialize a two dimensional array.
So it's this
and say we had another one let's get this well
in what's called Judy it has to
linked to in the row and the length three in the call games that's always row so your column is here.
So here's how you'd initialize this say in three
six K or six total elements in this array.
Right.
So in this case it would make a two dimensional array of two by three two rows and three columns of
like or.
Yeah.
And just like I said for and one to three would be in the first row.
OK.
So this would go into the first row and four five six would be in the second row.
And here's kind of a more intuitive way to initialize if we just say like this
then this is also a good way to initialize.
So you can group entire rows gather as well using these braces go even crazier than just two dimensions.
We can have as many dimensions as we want it really.
So we could have say hooray three like this.
So do three and four.
So this creates a three dimensional array.
It has two rows of three by four a raise if you want to think of it that way Oregon.
Think of it as having two rows three columns and four dead.
If you want to think of it that way as well we won't be using anything above a two dimensional array
but you can technically have as many dimensions that you want.
So we'll see how those interact with pointers in the next lecture.