 Hey everybody, it's Brian. This is our 15th C++ tutorial. Today we'll be discussing the while loop. See, we already have a variable called i, which is set to 0, and we're going to say while, parentheses, code block. You probably already guessed what this does. You have a while and then an expression we're evaluating, so we'll say while, i is less than, we'll say, 4 cout, i and l. So we're just going to print out the value with an inline behind it. Remember to increment our counter variable, otherwise it'll just loop forever. Let's run this and see what it does. Same thing, 0, 1, 2, 3. Now, why do you need two different types of loops here? Technically three. You've got the do loop, the while loop and the for loop. For loop is very handy for going through, like, a collection. We'll get into that later. Do and while are almost exactly a like. I mean, you've got while, i is less than four. That's almost the exact same thing, isn't it? Well, let's discuss the differences between these two really quickly before we end this tutorial. The while loop evaluates the expression first, then executes the code. The do loop will execute the code, then evaluate the expression. So if you want this block of code to always fire off at least once, use the do loop. If you want to evaluate the expression beforehand, use the while loop. Otherwise, they are almost identical in function and we're going to prove that right now. And we're just going to add a line return between these two. Run this, you can see what happens here. 0, 1, 2, 3 and then there's our four. Well, what happened? Remember, we start i at zero. So we're saying while and then it goes zero, increments, increments, increments. That's where our while loop stops right here when it's the hard return. Then there's four. What happened? Remember, the do loop always fires off. So we can even say starting... Wow, I cannot spell today. Starting do loop. Let's actually add another indel in here. So what's going to happen is we're going to go zero through three. Then we're going to say starting the do loop and then jump into this. As you can see, there's our while loop and then starting the do loop and you can see how it triggers at least one time. So this is executed before this is processed. Now, if you just simply reset i to zero, the function is going to be almost identical. I should say it actually is identical. So that is the while loop and we are comparing it to the do while loop. I hope you found this video educational and entertaining. As always, thank you for watching.