Hi.
Even so in this lesson we are going to learn how we can initialize our metrics.
Or you can say to damage and Larry.
So how do we initialize our one theory.
So we write like this and then let's say four elements and I will give four values.
That's a one two three and four.
So this is the way for initializing a the array.
Now how we can initialize our to the area.
So I will write like this.
I want to create a truly array of integers.
Many of the array number of rows and columns letter to roots and three columns and I will initialize
it like this.
So I will give one two entry.
So this is the content.
1 2 and 3.
So this is the content for the first row.
Now I have to give one rule.
So since then I will write 4 5 and 6
so that's how I will initialize my to the area.
So this will look like this.
I have two rows and three columns
so in the first row I will fill this element 1 2 3 in the next row.
I will fill these elements forward five and six so it is very simple to initialize I would do the 80
now in to the array basically giving rows is optional.
So giving rows is optional and giving columns is mandatory.
So this is giving columns item mandatory and giving the value of rules out optional.
And we will see why it is so but not in this way a deal probably in the next video.
So basically I can write like this also I want to create a airy I do not want to give rules and again
the columns I mean it is so we have to give columns.
And if I will write like this 120 and let's say in the next row four five six four five six and now
seven eight nine
okay.
So this is not this is only a comma
and then this.
So what will be my final edit.
So how many rules will be there.
So we can figure it out with the help of the number of elements that I'm trying to insert.
So I will have to use and the number of columns are obviously given three so three rows and three columns
what is the content of the first rule.
It is 1 2 3.
What is the content for the second group 4 5 6 and what is the content for the third 2 7 8 9 so that
is the meaning of giving it all this is optional.
Giving rules is optional but giving the number of columns in a duty Eddy is mandatory.
Now let's say Now tell me what will happen if I try and do something like this into V I do not want
to give the number of flues but I want to give the number of columns which are totally and what is my
content.
So let's say 1 2.
Now let's say 2 4 5 and now let's say 7 and 8.
So what will be my duty.
So 1 2 and 3.
So first of all I will have clear rules and the number of columns I've given three.
So this is two cross three three cross three.
What is the content for the festival.
The content for the first ROIs 1 2 1 and 2.
What is the content for the second 2 3 4 and 5.
What is the content for the third row 7 and 8 and what will happen to the values which are not provided
by the user.
So I will put zero there so this is just like one diary.
So in one diary if you will do something like this a 0 4 and you give only one value let's say 1 or
do you give 2 values then what will happen.
So basically you will get four boxes and inside the first row box then the values will be went in two
and rest the values will become zero.
So that is what happening here.
All the values which apply which I will not provide.
They will automatically become zero simple.
So let's take one more example.
So let's say if I would lose something like this I want to create a duty at let's say 5 loosely worded
and 4 columns are going to be presented and I give value like this one and two and then I give three
and four.
So what will happen.
So first of all I am going to have five rules and there will be four columns so first rule second rule
third rule fourth and fifth rule and this is first column second the third and fourth column.
So what is the content for the first rule.
This is one in two.
What is the content for the second rule.
This is three and four.
And what will happen to all the all these black boxes.
So they will become zero.
So zero will be placed every year
so this is the desired so I hope you understood.
Now I want to initialize my complete Matrix complete to the area with all the zeros.
So for example what I want to say here is
so how do you create an array with all the zeros.
How to initialize an array with all the.
Also you will have to write something like this in D3.
Let's say you want to create of size 10 and if you write it like this then what will happen.
So all the elements inside are ready.
So first of all this element is zero so that's why the first element will become detail and the rest
of the elements are going to become zero.
Now I want to initialize my to the area with all the zeros.
Again this index is way too simple.
Let's say 10 goes and 10 columns and you will write it something like this zero.
So what will happen again.
You will get a 10 cost 10 judiciary.
So this is 0 9 and again 0 9.
And all the values inside this truly array will visit was so zero as will be the
so net so we can initialize our duty metrics with all the zeros.
Simple.
So now let us try to print all this because I know we should not trust someone we should write the code
and then we should see what our output will be so let's say okay.
So first of all let us create a function.
So how do we create a function.
So let us create a function print Eddie
so this print data function what it will take it will take.
Obviously the eddy.
So do damage and Eddie will take how many to lose out there and it will take how many columns How did
than what they have to do so let's copy discord
I'm going to print the content of the judiciary revise and now let us comment everything from here.
So what I will do I will not take the input I will just vaguely call the function.
So
let us initialize our Eddie So let's say the.
I do not want to give the number of rows because giving them little photos are optional.
I just want to give the number of columns so noted the number of columns are two correct.
So now let us initialize them in it.
So the first let's say one comma two.
Now let's say I want to give to go my for.
So this is correct.
Now what you have to do so we have to call this function Big Daddy so let's call the function Bring
daddy.
So I have to pass the edit.
So let's pass Eddie so the value of passing the array is exactly the same.
We are passing the Eddy just like we used to pass in one dimension that in just the name of the ad is
in a then how many rows.
So there are two rows and there are two columns.
So the value of eminent in order to commit to correct.
Now one thing so this code is not correct.
Why it is not correct because I told you giving rules are optional but giving columns are mandatory.
So giving column some and it is all this is the same if you want to pass are to really giving columns
are mandatory.
So what I want to say here is just like I told you that when you are creating your to really giving
the values of rules are optional but giving the values of columns are mandatory.
Similarly when you want to pass an edit to a function.
So we want the possibility to a function.
So giving the rules so giving the rules are again optional but giving the number of columns are mandatory
vite is mandatory.
We will see it in the next review.
So this is too.
So that's why you have to write to here.
OK so let's test our program
so this is my output went to tea and food.
Now let's do some experiments now let's say instead of two if the number of columns out of five.
So what should be an output.
So again if you are making it five then you have to write five here also because the number of columns
should be seen.
So this value and this value they should be same This is the requirement.
And why this is the requirement.
We will see it in the next video.
So let's run our program
OK.
So one thing that I did wrong here is so the number of columns I actually 5 know Let's run again.
So now you can see so there are zeros peasant every year so this will be so 1 and 2 then then the content
of the second draw to you in full and then the all the three rest columns will become zero.
So this is the output.
Correct.
And again I'm repeating myself giving the value of columns are mandatory Vitus mandatory we will see
it in the next redo.
So you have to 5.
So this value and this value they should match.
Otherwise you get output will be wrong
now let's say.
Now let's say the number of rules are also five.
So if the number of rows at five let's change let's make five here.
So now let's try to test our program
so see there are you peasant every year so let me explain this output to you so again there are five
rules in five columns so you will get a five Gross five metrics the content of the first rule is 1 and
2 the of the second choice 2 and 4 rest they will be zeros every year so zeros zeros and zeros.
So that's why you can see how many zeros are there and can we initialize our duty metrics with zeros.
Yes we definitely we can.
So how do we initialize our duty metrics with zeros.
So let us create an identity let's say it b number of rows again optional.
Let's say there are five rows and five columns and I want to initialize my David all Aussie rules so
I will write to zero here.
Simple and I will call.
I will pass B at a
so you can see Zoe's present every viewer so in this we do we learned two important things first thing
is basically how to initialize our duty metrics how do initialize our to the data.
We learned how we can initialize over to the idea and the second thing is basically venue initializing
the to the edit giving the value of rules are optional but giving the values of columns are mandatory.
Similarly when you are passing so when you are passing your 2D Eddie to a function then the number of
rows.
So the value of you can give rows but giving the value of column side mandatory.
So when you are passing function and you are passing to the idea to a function so giving the value of
columns are mandatory.
So this is mandatory and their value should be same and giving that value for was not optional.
So this is optional.
Now the next we do we will discuss why giving the value of columns are mandatory.
So I will see you in the next one but by.