Wednesday, November 12, 2008

Do... Loops

Another few days, another few lessons, another few concepts. Do loops, which is the basis of all the lessons we've been learning for the past few days, allow you to loop certain codes, so that you don't have to rewrite them over and over again, and at the same time be able to save lots and lots of time.

Do loops require a do statement at the very beginning, and a loop after all the code you wish to, well, loop. There can be no do without a loop, and likewise there can be no loop without a do. They are always needed in order to fulfill the process of looping a code/function, and are very important in the computer programming world. However, a do loop also needs to end, bringing us to another new concept-- counter controlled repetition.

Counter controlled repetitions allow you to repeat a code a certain amount of times, and refrains the program from repeating the same function over and over again. To properly control these counters, we use do loop until, which, essentially, loops a program until (yes, the code speaks literally for itself) a certain extent. It can be used for a wide of variety of uses, including the ones we took example of today-- adding the sums of a long list of numbers.

Posted by Chris Kaminski at 5:38 PM