Afrikaans
Akan
Albanian
Amharic
Arabic
Armenian
Azerbaijani
Basque
Belarusian
Bemba
Bengali
Bihari
Bosnian
Breton
Bulgarian
Cambodian
Catalan
Cebuano
Cherokee
Chichewa
Chinese (Simplified)
Chinese (Traditional)
Corsican
Croatian
Czech
Danish
Dutch
English
Esperanto
Estonian
Ewe
Faroese
Filipino
Finnish
French
Frisian
Ga
Galician
Georgian
German
Greek
Guarani
Gujarati
Haitian Creole
Hausa
Hawaiian
Hebrew
Hindi
Hmong
Icelandic
Igbo
Indonesian
Interlingua
Irish
Italian
Japanese
Javanese
Kannada
Kazakh
Kinyarwanda
Kirundi
Kongo
Korean
Krio (Sierra Leone)
Kurdish
Kurdish (Soranรฎ)
Kyrgyz
Laothian
Latin
Latvian
Lingala
Lithuanian
Lozi
Luganda
Luo
Luxembourgish
Macedonian
Malagasy
Malay
Malayalam
Maltese
Maori
Marathi
Mauritian Creole
Moldavian
Mongolian
Myanmar (Burmese)
Montenegrin
Nepali
Nigerian Pidgin
Northern Sotho
Norwegian
Norwegian (Nynorsk)
Occitan
Oriya
Oromo
Pashto
Persian
Polish
Portuguese (Brazil)
Portuguese (Portugal)
Punjabi
Quechua
Romanian
Romansh
Runyakitara
Russian
Samoan
Scots Gaelic
Serbian
Serbo-Croatian
Sesotho
Setswana
Seychellois Creole
Shona
Sindhi
Sinhalese
Slovak
Slovenian
Somali
Spanish
Spanish (Latin American)
Sundanese
Swahili
Swedish
Tajik
Tamil
Tatar
Telugu
Thai
Tigrinya
Tonga
Tshiluba
Tumbuka
Turkish
Turkmen
Twi
Uighur
Ukrainian
Urdu
Uzbek
Vietnamese
Welsh
Wolof
Xhosa
Yiddish
Yoruba
Zulu
Well, hello there, ladies and gentlemen, and welcome back to our Alphatech Academy program in Chorus.
My name is tech teacher Vlad.
And in this video, in this lesson, we're going to talk about a looping control structure called Ferral
Loops so we can save it.
A for a loop is also a loop, and it's simply used to execute some commands at the loop body over and
over again.
As long as the loop condition is satisfied.
This type of loop is also sometimes called a counting loop.
And we will see why right away.
If we compare it to, let's say, the while loop, we can say that while loop only contains a condition,
but the for a loop will be slightly off a different structure.
Okay, so the for a loop looks like this.
First of all, like with the wire loops, you first use the statement for two star there for a loop.
You specify that we are that you are working with a for loop.
Second, there are going to be three very important sections that are used to construct the for itself,
the force structure itself.
The first one is the initialization statement, which will be executed just once.
Please note it will be executed just once and it will be when we encounter the for loop for the first
time.
It's sort of the starting point of the loop.
Okay.
It's just the first time you admitted you executed.
Sometimes it's even called the variables initialization phase, and that is you.
It is being used for the initialization of variables which are going to take a major path in this loop
functionality.
You will see exactly why we are creating an initializing these variables.
So the second section is actually the loop condition.
The second section is going to be the loop condition, just like the loop condition we've seen in the
while loop.
Nothing special.
It's just a condition that may be either a true or false.
And as long as these specified condition is not false, meaning it's true, as long as these condition
as the loop condition happens to be true, we are going to execute the body of the loop over and over
again.
And at the end of every duration, we are going to have the update statement.
So lastly, we have this update statement.
And this particular piece of code in the subject statement will be executed at the end.
I mean, whenever we finish a given iteration at the end of every iteration, we are going to execute
these updates statement.
There are going to be a couple of commands, maybe one, maybe non, maybe two.
And they are going to be executed after after we have finished a given iteration.
So at the end of every iteration.
So once a given iteration is over, you go to this section for this updates statement and you run its
updates and go checking me out of the loop.
Condition has been changed.
Now it's maybe either a true or false.
Based on the update.
You've done so far.
And if it's false, you are going to execute two.
Or if it's true, you're going to, of course, run the loop body once again.
Now, before we jumping to coding and see how it works in our programming language, I want us to take
another look at a general explanation, a general visualization of the four of the four loops and why
and how it's being used.
Some some example that I think can be nice for you guys.
Okay, so we have a program with a bunch of commands and we come to a point where we see the forest
statement for the first time.
And that basically means that now we know that we are going to deal with a for loop.
So if we need to deal with a for loop, we first of all, the first thing that we do is we are going
to run the first section that we've previously discussed, the loop initialization step.
So we execute the commands specified in this section just once.
All right.
So in these looping stylization, there are going to be a couple of sections.
And the first one is the initialization.
And in this example, we can say that this first step is executed just once.
So let's assume that it's kind of the fact that Mike's mike arrives to work, OK?
It's just executed once and now.
And now, once Mike arrived to work, we can check if the loop condition, for example, his task,
Mike's task is to do some work.
Let's say, for three hours straight.
And that's the condition if these work has been done.
So we are going to check if this condition is true or false.
And if this condition is satisfied, we are going to execute the loop body once we are executing the
loop body we have.
We can say that we have completed an iteration.
You remember that, right?
So in the loop body, the Labadee execution consists of, let's say Mike has to think what to do and
to code something and then to fix some bugs.
Right.
This is just a one iteration.
He does.
He's three hours straight work in a couple of iteration and in four loops once some iteration is complete.
We should go to the update section and execute the commands specify.
There you can see the commands in this section as commands that are used for preparation for the next
iteration.
All right.
Just look at it this way.
So now you will remember that you have to execute them every time after a certain iteration is completed.
For example, every two.
After every iteration, Mike is going to get something to drink.
I don't know.
That's that's the update statement.
And also, he will mark that he finished one hour of working.
And now once you're done with the update section, you check out the loop condition once again and execute
the loop body based on its result.
And basically, you go over these steps over and over again until the condition will be false or until
you will have some breaking command that makes you out of the loop.
That's something that we are also going to discuss in the next videos.
But I think you've got the point of how for loops work, you initialize, you check a condition, you
run the loop body, and then you prepare for the next iteration by running some update commands.
And once you do so, if you do so correctly, your four loops are ready to go.
So now let's take a look at how it can be used in our programming language and also understand when
using the four loops is preferred over using while loops.
I hope you're ready, guys, and I'll see in the next video.
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.