Hey, guys, what's up?
So in the last class, we learned about four loops, and I told you that.
We will solve some problems with the help of follows to get a better understanding.
So this is the first problem.
So the problem statement is very simple.
We just have to multiply two numbers, but without multiplying them, without multiplying them means
you cannot write A multiplier by B.
So this is wrong.
But you have to multiply the numbers.
So we all know that image by baby is him as addition of a B times.
OK.
So if you want someone to bear to multiply by three.
So this is two plus two plus two.
That is added to three number of times.
So six.
OK.
So you multiply by B's same as add a B times.
So I need a loop and this loop will run B times.
So each time this loop is running, what I will do.
I will maintain a variable sum.
And I will do some equals.
Some Plessey.
OK.
So this problem can easily be solved by via loop.
And this problem can easily be solved by a for loop.
But I will solve this problem with the help of for loop so that you get a better understanding of how
for Lookbook we have done enough number of Papis on y loop.
Now this is the time for practicing a little bit of for loop.
OK.
So I think you understand the logic.
So logic is very simple.
For example, if you want to multiply two into five, what you will do, you will add two to five times
as two plus two plus two plus two.
So this is 10.
Similarly, if you want to multiply B eight, multiply baby.
What do will.
You will do something like this.
Eight plus eight plus.
Say how many times.
B times.
OK.
So what is multiplication.
Multiplication is actually nothing.
Multiplication is actually anything we can call it as it is repetitive.
It is repetitive addition.
So multiplication is nothing.
It is just repetitive additions.
So our logic is very simple.
I run a loop been a matter of times and each time you are running a loop, we will mention a variable
sum added to the variable sum.
OK.
So now where does all this problem?
So let's hear the name of this is.
So what should we name it, multiply?
So we are naming it multiply, not CBB.
So what we have to do first.
I will take in a motel, then put slatted in a Mazari and we will give us the valley of envy and we
have to work to play in the valley of.
And be lucky.
So what I need.
I need a loop.
And first of all, I need some initialism will be zero if you will not initialize the sum will contain
garbage value and the output will be wrong.
So initiation of some is very important.
Not the for loop.
How many times we have to run this loop.
We have to run this loop B times.
So I equals.
So I equals when I last 10 articles to be a plus plus.
What do you do.
You will add the value of a two sum.
So some equals simplicity.
And finally you will print the value of some.
Now how to check whether my output respect or not.
What will I do?
I will also print C out in to B.
Okay.
So now let's see whether our logic is correct or not.
Let's say the first number, the well, your face 20.
And my second number is.
Let's see if I have 24.
So.
Our our.
Correct.
So one zero four zero.
So the first one is due to some.
And the second one is due to a multiplier baby.
So our court is hundred percent correct.
You can also implement this with the help of my loop.
So what do we do if we want to use VI loopier?
So our logic is very simple.
You will, right, and I quote one while now you will read the condition.
Condition is listed in articles to be.
You will add some because some plus eight.
And then you will write a plus plus.
OK, so this is my condition.
This is my condition.
This is my initialization.
This is my condition.
And finally, this is my condition.
Sorry, this was subdued.
This was update and this is update.
OK.
So the principle behind the working off fall of NY Loop is exactly same, when the next we do, we will
solve one more question to get a better understanding or for loop.
OK.
So this is it for this.
We know if you have any doubt, feel free to ask.
Thank you.