Here we introduce the FOR loop, a powerful command with great versilitity
This seems a reasonable way of generating the words of the class alma mater -- But notice we have repeated the same line three times. There is almost always a better way to do this.
Writing computer code is a slow and painful process. One way that we get more good out of the code that we write is by repeating the same code over and over.
In fact, repetative processes are one of the things that computers are very good at. The FOR is one of the ways of writing a loop.
This is just a small modification of the previous example
to put some commas in place.
A fundamental rule: If the output
looks good, it is because some programmer worked at it
/*Here is a new trick -- a FOR loop inside of a FOR loop. This can generate
a lot of program activity since the inner loop runs completely for each
time through the outer loop. In this example the inner loop "for i = 1"
runs three times each of the times through the outer "for j = 1"
loop. Since the outer loop runs three times, by the time the program is
done the inner loop has run nine times.
Imagine what would happen if you put a third loop inside the second
loop! Can you do it? The words to put in are "fa la."*/
/*I put a third loop inside the second
loop! Is this what you tried? Notice that I added a variable
and changed the spacing*/
This page is at: http://testbed.cis.drexel.edu/Cindex3.html