Hello, guys, and welcome back to the calls.
In the last lesson, we covered three problems off part one.
So to really be solving three problems of part two.
So problem one.
So the president's statement is.
Read in numbers.
And bringing to their average Brent, their average.
So if you remember, we have already covered the simple version of this problem.
The problem statement was we have to read five numbers and we have to print their average.
And the flowchart was something like this.
We start our program and then we read five numbers, read A, B, C, D and E.
These are five numbers, and then I have to calculate some, which is summation of all these numbers.
And then I have to conclude my average, which is equals to some by five.
And then.
I will print average.
After printing average, my work is over.
And then I will end my program.
So this is the simpler version of this problem that we have already covered.
So what is the difference between this problem and this problem?
So the defense is very clear in this problem.
I already know that I have to read five numbers, so I make five variables.
ABC d e.
But then this problem.
I don't know.
How many variables do I have to make?
I don't know the value of and value of and will be given by user.
So I don't know how many variables do I have to make.
So our first problem is to how to read and numbers.
How do read and numbers?
So this is our first problem, how to read and numbers.
So what will I do?
I will run a loop and times.
I will run a loop and times and each time I will read no, read no.
So in total, this loop is learning and times and each time I am reading a number.
So in total I will be reading in numbers.
So our first problem is a lot of reading and numbers.
OK, so how we learn loop and times.
So the answer is very simple.
I will use these two condition.
I was one I less than or equal to N.
And I it was a plus one.
So using these three blogs, I will be able to run a loop and times and each time I will do that number.
So in total, I will be able to read and numbers.
So the first problem is, oh, we're operating in numbers.
Now, the second problem I have to calculate average.
So average equals to some of.
All these numbers.
Some of all this.
And numbers, why did why?
And so I know the really often which will be given by user.
I have to convert this part some of all these numbers.
So what will I do?
I will use a variable sum.
Initially, my son will be zero.
And when I am reading my name, but I will add this number to the current sum.
That is some equals.
Some bliss number.
So rude.
No, at this number two, the current system.
So when this loop.
Wait a minute.
That is after running and times in my variable sum.
I will be having some of all these numbers and then I will easily calculate the value of average.
And then I will point average.
OK.
So let's roll the flow chart.
So start.
And then I have duded and.
And then I will take a variable eye, which is initialized to win because I want to add an eye loop
and Pym's and my sum will be initially zero.
Now we'll check the condition is I left the Noriko's to end.
So if this condition is true.
Now I'm inside the loop.
What will I do?
I will read no you the number.
And after reading this number, I will add this number to my current sum.
So the new value of some equals over the value of some, bless the number that I have read.
I close, I listen because I want to run this loop and times.
So this loop villain and times each time I am reading a number.
And after reading that number, I'm adding this number to the current sum.
So when this condition will become false.
So my average will be some divided by and.
Sam is storing some of all those numbers, and after calculating average, I will print average.
Now my work is over.
I will end my program.
And.
OK, so let us take an example, let's say the really off and is three and the numbers are one, two
and three, so numbers are 120.
And I'm having total TNM was.
So what is the average?
One plus two plus three.
All elevated wady letters to.
Okay, so I started my program.
I read in an enclosed tree, I close one semigloss zero.
So I it was when some equals zero.
And then I will come here.
Is one less to know, note goes to three.
Yes.
Come here.
Read a number.
OK, read one.
Add this number to the current sum.
So sum, it was zero plus one that this one.
OK.
I equals I plus one.
So the new radio fi is.
All vilify.
Which is one plus one that this, too.
So new if I is to and then you have to come here.
Is to list the Noriko's two three.
So the condition is again through, you will come here?
No.
This time I will do so.
The new valy of some will be all will leave some place.
That number that you have read.
One to two.
Destry.
OK.
Now you will come here and given really if I buy one.
So the new value of fi will be two plus one.
That is three.
Jack Deconditioned again is three, Lester goes to three.
So the condition is again through, you will again come here.
Greed.
Number three.
Some equals.
All three of them, plus the number that you have read.
So three plus three letters.
Six in commander commendably if I buy one.
So the new vilify is always lo fi.
Which is three plus one at this food.
Check the condition again.
As for less tornadoes, two, three, no, so a condition is false.
And this loop will break again.
So average equals some, which is close to six divided by N and is three.
So my averages do.
And then you will bring to an average.
So, too, will be printed.
And you will endure program so for this do, which is hundred percent correct.
Okay, so.
Let us revise what we have done, so I have to read in numbers, and I would do bring average.
We have already done a simple evasion of this problem and that problem.
I have read this five numbers and I have to bring the average of those five numbers.
So what I did, I tried my program, I read five numbers.
I make five variables.
And I take the values of those five numbers.
Then I concluded some.
Then I concluded average print average and end my program.
But the first problem of discussion is how I will read in them was.
I can't make any variables because I don't know the value of an the value of and we beg you and my user.
So this is very straightforward that I cannot make any variables because I don't know the value of an.
So what we will do.
We will run a loop and times is using these three blocks.
I will be able to run my loop and times and each time I will read that number.
So in total, I will be able to read and numbers.
OK, so first problem is over.
Now let's see that problem.
I have to print that average.
For calculating the average, I read some of these numbers for calculating some.
What will I do when I am reading the number?
I will add this number to the current sum.
So the new value of some goes to or value of some plus the number that I have read.
And then when this loop will terminate, when this loop.
Wait a minute.
That is after this loop at an end times.
My variable sum will be storing the sum of all these numbers and then I will calculate my average using
this formula.
OK.
So.
Let's look at the flow chart.
Okay, let's take another example, let's say any equals.
Two, and then the Mossad.
Four and six, so averages four plus six.
By doing that, it's five.
OK, so start with you then I equals one time it goes zero.
So I equals one.
Some equals zero.
Come here.
Is one less than already close to two.
So the condition is true.
Yes.
Come here.
Rude.
No, I will read for them here at this number.
The current sum.
So some equals zero plus four letters, four.
Okay.
Come here and go under.
If I, I went to the new Bailey, if I will be to check the condition again is to list Donna goes to
do for the condition is true.
Yes.
No.
This time I will read six.
Add this number to the current sum.
So sum equals four plus six.
That is 10.
And given the value if I buy one.
So I.
It goes to bless one.
That is three.
Check the condition again is three less.
Then I go straight to.
No.
The condition is false.
So you will come here.
OK.
Calculate the average average equals sum divided away and add the value of.
And is to.
So average equals five, then Brint average.
OK, five for Lubricator and then endure program.
So I am burning five and average of four and six is five.
So I went flowcharts hundred percent.
Correct.
Like, that's all.
And the problem.