Transcript for:
Program Logic and Design: Comparing Selections and Loops

welcome back to program logic and design in this section I'm going to be discussing on comparing selections and Loops here I have a single alternative selection structure over here you'll see that both structures a loop structure and a selection structure both start with a Boolean expression in other words a little diamond shaped decision symbol you'll see that they have if something is yes in other words if this is true a structure will occur so in other words something's going to happen when that is true but this is where they are different when there is no or yes so either way for a selection structure whatever comes subsequent step that follows at the bottom here so whatever is stacked at the bottom here will still occur whereas for a loop if there is a no this will not occur so you will not enter to the loop if this decision is false if this decision is true then you're going to go into the loop and you are going to do the structure and you going to do the structure over and over again until this has been falsified until this the value has been falsified so a selection structure has two logical paths true or false that join together a loop structure has one of the logical path branches returns to the same decision so to the entry of our decision now this is logic mistake which we do is that when we not end a file we display the record and we input the record not end a file display record input record not in the file display record input record so we can do this for as many times as possible but it's not necessary to actually do all this repetitiousness because the thing is here is that you don't know how many how many records are in that file so you could do this five times but maybe there are 10 records in that file then you are eliminating five records of that file so to eliminate this repetitiousness it's much easier to just put it in a loop so you'll say not end a file display the record input record not in the file display record input record so you will not only do 10 records but if you add on an extra five records 10 records an extra 10 million records it will not matter because you will not have to keep doing a selection structure selection structure selection structure for not end the file you can just simply have it in a loop and you're allowing the program to run smoothly eliminating areas in your code it just makes more logical sense and what we doing is it's efficient and it's structured please join me in the next videos in which I'll be disc starting the introduction to arrays and subscripts