welcome back to programming logic and design in this section we're going to be discussing the for Loop now a four statement or a for Loop is a definite Loop when I talk about a definite Loop a definite Loop is a loop that's going to execute a number of times definitely so it can execute three times four times for instance if you have a look at this example it's going to execute exactly four times 0 1 2 3 four times remember we are count ing from zero and including three so what's actually happening is three actions are being performed automatically within the four statement we are initializing 0 count to be zero then we are evaluating our count to whether it is equal to three and then we are going to alter it in other words we are going to step it up one so if it was at zero we're going to step it up one to be one and then we're going to evaluate it against the number three and if it is equal to then we are going to ex the program if it's not equal to then we're going to Output hello for you to understand the for loop we're going to have to play computer in other words we're going to desk check a bit all right so we have count is equal to zero the count is being initialized to zero here through to three so we are going to be evaluating how we going to evaluate is if our whatever our count value is less than or equal to three so in this case 0 is less than equal to three and if that is true then we're going to type true if that is false we're going to type false and if it's true we output hello which in this case it is true and then we're going to alter our count value so two three step one it means we altering our count value so we're going A4 which is our original count + one is one so now count is one so we evaluate 1 against three and less than equal to three which is true we output hello and we alter one now to be two so now count is two is two less than and equal to three yes it is then we are put hello now we alter our count variable which is two two is 2 + 1 is 3 we count is now three we evaluate that to less than equ Al to 3 which is true is equal to three we output hello then we alter our three so 3 + 1 is four count is now four we evaluate count to our condition which is is count is less than equal to 3 is 4 less than equal to 3 it is false so therefore we exit the loop so this statement here we are checking the count value against the limit value three so I limit value three meaning that it must be equal to three if the value evaluation is true then of course the statement body which is hello will be executed and outputed now if you had to compare our for Loop to our while loop these two actions execute the same way if we had to compare the for Loop and the wild Loop you can see that with the while loop we have to initialize count at the beginning before we enter the loop then we have our evaluation here of our well Loop then we output hello if this evaluation is true and then we increment count then we loop back up and check our condition we evaluate our condition print out hello if it's true and increment notice here we have five lines of code whereas here we have only three lines of code so therefore the loop control variable is handled automatically by the for statements and therefore we have fewer lines of code in our for Loop fewer lines of code equals an increase in your processing time so in conclusion our step value is the amount by which the loop control variable is going to change so it can be positive or negative in other words incrementing or decrementing The Loop control variable its default step value is one now a programmer can specify a step value when each pass through the loop changes the loop control variable by the value other than one so you can use 2 3 4 5 six you can increment it as as many values as you want here is a lovely quick reference to how to use the four Loop you have your four and your N4 which are your keywords please note that your Loop control variable this will be whatever variable you name in this case it was count your initial value you can start at zero you can start at one you can start at two depends on your program your final value will be what how many times you are going to have your program iterate and how many times in other words how many times you're going to have your Loop repeat to what value will you repeat so always make sure that count from your initial value to your final value to make sure that if it is four then you count your initial value should be 0 to 3 or 1 to 5 then your step value will be what you are increasing by in this case you increase by one if you it's going to be 0 1 2 3 4 you can also make it all even numbers so it will be increased by two so 2 4 6 8 10 in the desk checking you saw that the while statement could be used in place of the four Loop now you get two different types of Loops you get the pre-test Loop which is the loop that's controlled variable is tested before each iteration and then you get the post test Loop which the loop control variable is tested after each iteration so your for loops and your while Loops will be your preest Loop and your post test Loop will be your do while or your do until Loops please join me in the next video in which I'll be discussing common Loop applications