Hey, guys, what's up?
So today we will learn how to pass any dual function.
Okay, so this is the topic for today's class.
How to pass at is indoor function.
So let's see the goal.
So I even named this filer's biasing idea to functions.
So let us first take how many number of elements are there in entity the scene.
And now let us make NRD offsides.
And now let us take and loses input.
So forward.
And I equals zero.
I illest and n a plus.
Plus.
So in a off I.
OK, so what we do is let us create a brain function that will print.
So I have a brain function.
So what brain function will take it will take a.
Which is Eddie as input.
No, no, that's right.
Brain function here so that you don't die will be wired because brain function will not return anything.
It will just print the content of the edit.
So you have to write and a if you will write into it means an integer.
So you have to write like this.
This means any.
And now you have to just print.
So for printing what I have to do, I will just I did already.
So Ford and I equals zero.
So this isn't normal logic, but that above, which will bring the content of the ERRY, but here I
am using a variable and so I have to take the size of the eddy as well.
So similarly, I will print.
I will pass the size of the eddy as input.
Okay.
So this is important.
We have to also pass the size of the areas in Bertolli.
Function.
So there are five elements and the elements are two, four, five, six and three.
So the values are getting printed.
So this print function is printing the content of the eddy.
Now, let this come into doubt.
So now what we want to do is we want to find the sum of all the elements of the eddy.
OK, so let's do it.
So what this function will return, this function will are done, some of the elements.
So this function will be done and integer value.
So intenser equals, let's say the name of the function is some what it will do.
It will take as input and also the size of the eddy.
Do I date of the 80.
So this is important because if we don't know the value of n how we will do that with the.
So that I don't type of dysfunction is.
And because we have to retain the same name of the functionalism, it will take Eddie.
So.
And Eddie.
And it will also take the size of the Eddie.
Now we know how to find this out.
The Eddie.
So and answer is initially zero.
We have to initialize our answer with zero.
Otherwise it will contain garbage.
You know, we just have to hydrate.
So four and I equals zero.
I less than an A plus.
Plus, we will add the current value to my answer.
So answer plus equals eight of a..
Now this is all that we have to do.
Finally, after calculating this, um, we will return that sum to the calling function, which is mean.
And after getting the sum here.
After getting the answer.
What I will do, I will.
Brent Sum.
Brent.
Answer.
OK, so let's test out program.
So in some coma.
So I'm dining.
Sorry, head will be answered.
So there are, let's say, three elements, Nedry and elements are 120.
So I'm out four days.
My some of the elements are six.
If there are, let's say, five elements and the elements are one, two, three, four and five, four
or five and let's say when.
So I produce four degree 34 plus five.
Thirty nine plus one.
Forty, forty two and forty three.
OK.
So this is how we will pass Eddie to the function.
So we have to pass two things first.
So we have to pass two things.
First, that Eddie and second, the size of the area because we have to ideato the Eddie.
Now, the most important thing they are going to discuss is Eddie, are always biased.
By their friends.
So Ed is always passed by the fence.
So what is the meaning of this statement?
Let's see.
So, for example.
If I will change the value.
So let's see.
I am changing the value of the first element.
Let's say the value is five.
So this value will be changed.
Now, I am printing daddy first.
Daddy.
And after calculating Lissome again.
Vendetti.
So print a comma and.
OK.
So let's come it out.
So what we did is we just changed the first reilley of the area.
Suppose there are five elements in the array and the elements are one, two, three, four and five.
So you can hear the element was one.
Now, the first element has become five because I have written I have changed the zero index value of
zero equals five.
OK.
That is are always passed by reference one more time later.
There is only one element and that element is three.
So first we will do the normal print three.
And after we call the sum function, some function will change the value to five.
Then five is getting printed.
So let's see.
So what is happening here?
First, you are calling brain function, brain function will normally print the content of the array,
then you're calling the function some.
Some function is changing the value of a of the zero.
OK, and then you are again printing, Eddie.
So this is normal input that I am printing of zero, then I'm calling some function what some function
will do.
It will change the value of a of zero to 123.
And finally, after calling the function some, I am printing the value of a zero again.
So let's say there are five elements in the area and the elements are one, four, five, three and
six.
So the first value of zero.
You can here you can see.
So if zero is one and a Odilo becomes a 123.
OK, so why it is so.
Because it is are passed by their friends.
OK.
So if you have any doubt, feel free to ask.
So this is it for this video.
Thank you.