Here are the three parts of a for loop, and how to remember them:
Initial-Action: This is where you state what a certain value equals. For example i=0, we are stating that currently, i is equal to zero. This is easy to remember because it’s the initial value, it is current.
Loop-Continuation-Condition: This is part of a for loop that determines when the loop starts. For example, i <10. As long as i is less than ten, the loop will carry on. When i becomes greater than or equal to ten, then the loop will stop. This one is easy to remember because it’s the condition, on what condition does the loop stop, and on what condition does the value make the statement false?
Action-After-Each -Iteration: This is the last part of a for loop. This part of a for loop tells you what to do with i after the loop is carried out one time. For example i=i+2. Each time the loop carries out, i will equal the current value plus two. This is easy to remember because it’s what happens after a loop, the ACTION that takes place once the loop is over.
Leave a Reply
You must be logged in to post a comment.