Conditional loops.
In the previous section, we gave a controversial example where the condition in the for loop pulled
from the data.
In this example, there is a null variable used in this condition.
This is a candidate for the while conditional loop here.
So while here.
Okay, let's make it like that.
My data bull my data and make it true.
Here and while my data here then integer here my data or we can make it into here.
Okay bull here my data and STD.
STD or C out E here and N line here.
As you can see, it created and printed a bunch of ones here.
So this means true here.
This statement will continue to loop until the expression, um, has a value of false here.
So as with four you can exit the while loop with brick return true or go to keywords and you can indicate
the next loop should be executed using the continue statement.
So the first time the while statement is called the condition tested before the loop is executed.
In some cases you may want to you may want the loop as good at least once and then test the condition.
So most likely depended upon the action in the loop to see if the loop should be repeated.
The way to do this is to use do while loop here.
So now let's make it my data false.
Pulse.
Here.
As you can see, we printed nothing.
But if we do the do while loop for example, do do here.
Uh.
Okay.
Is she out e here or my data here?
And line.
And.
We're going to add the file here while my data.
Here, as you can see here.
So let's print it out.
As you can see here, it printed zero because the with the do while loop the do condition here do code
here has to be executed at least once.
So this executes and when when our code tries to find out if my data is true or false, it returns the
false.
And that's why it printed only once here.
But in this case, it printed no nothing here.
So the, uh, here semicolon after this is required here, this is a class.
So, uh, as you can see here, this loop printed, uh, once here, false, despite of my data having
false here.
So the difference between two types of loop is that the condition here, the condition is tested before
the loop is executed in the while loop.
And so the loop may not be executed in a do while loop.
Here the condition is called after the loop, which means that with a do while loop, the loop statements
are always called at once.