Computer Programming: Loops

At the Linden SDA school the students have continued to work on the computer programming curriculum. The students have been asked extensively to learn how to program through the use of flowcharts. Along with the initial call symbols such as the oval (start and end), rectangle (process), decision (rhombus/ diamond), we added new symbols for input and output (parallelogram). All of these concepts together can used to effectively plan a program. Here we are going to create a loop.

A loop is a computer process in which certain actions are done until a condition is met. In most cases a condition is met and there is a way out of it. For a programmer being caught in a loop means they made a logic error in planning. There are a few aspects needed to create a loop. First you need a parameter, a preset limit created by the user. This can be an algebraic expression like x >10 or a wall that is in a robots way. The next thing is that the program needs to be incremented (increased) or decremented (decreased) to reach the parameter. In the flowchart that would be done through process symbol. To make the actual loop we would put the parameter that we want in the decision symbol and have an arrow to flow it back to the process box after the condition is not met.

This is a flowchart drawing made by a 6th grade student. They added the input symbol to their flowchart.

After the loop we put an output symbol with the result of the loop after the condition is met. In that symbol we would place the result of the program. So in the picture above x >9 is the parameter, x+2 is the increment and x=1 is the input. The loop would take the 1 from the input and increment by 2 when it hits the process. After that it would compare the new value of 3 and see if it is greater than 9. If it is not greater than 9, it will loop back to add 2 till the value is greater than 9. In the end the output would be 11 and placed in the output symbol. Then the program can be ended.

Post comment

Your email address will not be published. Required fields are marked *

© 2015 DIVAS for Social Justice Inc. All rights reserved. WordPress theme by Dameer DJ.