An array is a series of elements with the same data type that is placed in contiguous memory locations.
So this means that the memory location is assigned in consecutive memory blocks.
Since it implements the contiguous memory locations, the elements of the array can be individually
accessed by the index.
So let's take a look at this diagram here.
Here.
Let's say we have the five array.
So these are the memory addresses here.
So let's actually write it, the memory actually here.
So these are the memory addresses we will write here here by now.
So these are the memory address.
And we here we have the also we also have.
The and are here at the bottom that we write as 012, three, four is indexed of our array.
So here these are the index.
And as you can see, let's actually put some variables in them.
So here, let's say we have the 21.
Oops, not like this.
We just want it here.
Marker.
So here, let's say this is 21 here.
21.
And this one in the first index is 47.
And then 87.
69.
And.
35.
Mm hmm.
And here, as you can see here in this illustration, we have an array and containing five elements.
So since the array uses zero zero based indexing, the index starts from zero.
So this index is used to access the element value and also replace the element value.
So the memory state address is state in the illustration is, for example, purposes only.
You can see here.
So this is just an example purposes only in your actual computer.
In reality, the memory address might be different.
So however, it illustrates that the memory allocation is contiguous here.
But sometimes it might differentiate and like memory location might be random here, which you will
learn about them in next lectures.
So now if we want to access the preceding array or let's actually create this array in C plus plus code.
So let's get started first.
Actually, let's make it the bit right here.
Oops.
How can we select all of them?
I guess we can't.
Yes, we guess we.
Here.
These are the copy.
Yeah, we can hear.
So make this here.
Get this marker here.
Uh, the cursor here.
So first we implemented using STD here.
And also your stream because we're going to use the key out and other.
Functions.
And here we're going to initialize an array here.
So our first array integer.
Integer.
Integer array here or my array and here.
It's going to be the 21.
47.
47, 87, 69 and 35.
And as you can see here, the IntelliJ idea tells us that this is here.
Let's actually, as you can see here, the index zero here, index zero here.
Index zero is 21.
As you can see here.
It writes it like that.
Oh, here.
Index is 21.
The index one is 47.
Index two is 87.
The index three is 69 and index four is 35.
Here.
So now we need to access each element after this code here.
So let's actually create a get the cursor here and now we're going to access elements with this key
firstly, so we tell the user that we are array elements.
Array elements are or array elements, just an array elements.
And after that.
Here in the line at the here.
And now.
We're going to create a for loop.
So for integer for integer here, zero while the integer is E is less than size of our array, size
of our array or my array size of my array.
Then so size of we will also need to get an integer size so we will divide size of our pointer array
here, my array.
And after that we will increment e by one in each iteration and we will print this of course here array
my array.
My array here is E and here after that inline.
Line.
So that's it.
So let's actually run our program and see what happens.
So first let's go to Command Prompt.
Full screen.
Our file was.
Yeah.
G++ main.cpp a dot exe here.
And as you can see here, array element starts from the 21 actually let's make is like that array elements
after that new line.
But instead of new line we can also write it like this and line here it's the it will give us an same
output compile it again close and open a dot XM.
So as you can see here, we have here our array elements is first array element is 21, then we have
47, then we have 87.
And then we have 69 and then we have 35 here.
So now let's actually try to manipulate our array elements in the next lecture.
So I'm waiting you in the next lecture.