Hello and welcome to the 25th tutorial and c++ programming series and in this problem we'll have to do while loop loops essentially allow you to repeat code which helps release code and maintain maintain code a little bit of we will do while loop is run at least once the whereas a for loop or a wallet that we've locked in the past two to two tutorials, you will have noticed that for the actual code to be run a certain condition has to be met. Whereas the do while loop the code inside the loop will be worn at least once because the air conditioning and check until the loop has ended. This is actually a loop which I believe and from what I've seen you use less after commit for a while for I would say you use the most while will be both a close second and do while you will not use that much.
There'll be just certain instances that come up and you'll think yes do board seats it so much better than before. A wall because I don't have to do any extra stuff because I want the code to be run at least once is to show you how it works okay so what we're going to do is create a variable called assign the value six to it then the syntax for do or looping you do the keyword do in curly braces and then after the curly braces you can be on the next line on same line you put why you're so this is your condition for the conditional while i is less than five and inside here we're gonna print out an STD C and print out or STD and why And we're going to just increment here. So it's very similar to a do while loop in the fact that the actual loop structure only release to contain the condition was this moment, but it is known.
Okay, so this is very similar to a wallet in that the actual structure, the loop only needs a condition. Any variable setup needs to be done before so for the iterator, and anything that will affect the iterator needs to be done within the loop itself if you want it to be done for less brokenness move them around and say six, but it doesn't run after the arrow because if you have a look it declare the variable code. And it runs this code. So just prints out any i plus plus Oh, you know, seven, nine check is seven less than five. No. So I think He needs to run the code at least once a few if I were to change this to four or change the frequency incrementally, can you free the free for me the free prints are free and then free plus equal one or free plus plus.
And also does four equal an e4 less than five? Yes. So go back to the top here, print out for four plus plus which equals five is five less than five now so we continue then x it's the problem. That's it for the world. It's that simple. In the next part, we'll be looking at range based loops.
If you have any questions feel free to message us as well as on our system the quality the email will be in the description as usual. You can comment on the videos directly messages via YouTube as well. They're all the recording for source code will also be in the description. And as usual, thank you for watching and how can I help you have a nice day