Computer Science Canada Quick Tutorial on For Loops |
Author: | batman [ Wed Mar 01, 2006 4:14 pm ] | ||||||||
Post subject: | Quick Tutorial on For Loops | ||||||||
Heres a quick tutorial on for loops. A for loop is much different then a regular loop. A regular loop repeats a section of a program till it is exited or stopped using the exit statement. Example:
This will repeat the words "Hello World" till exited by the user. A for loop is different. Heres a basic example of one.
This program outputs the numbers 1 to 10 down the screen. What's with the "i" you might ask? The "i" is a variable of course. when you right a for statement you are allowed to declare a variable but that variable can only be used inside a for statement. If you try to use it outside the for statement then there will be an error. Ok so now you know the basic of a for loop. Using this knowledge you can do all sorts of things using the for loop. Do count backwards, just place the word decreasing after the for. Example:
This code will count down from 10 to 1. You can also do something like this.
Place the word "by" after the numbers, in this case there 10 and 1 and choose a value to count down from. This code above will count down from 10 to 1 by 2. That was my quick tutorial on for loops. If you have any questions of for loops just email me and i'll be glad to answer them. |
Author: | Booya [ Wed Mar 01, 2006 4:40 pm ] |
Post subject: | Tutorial on For Loops |
Nice tutorial on for loops. I understand it a lot now. Thanks! |
Author: | jamonathin [ Wed Mar 01, 2006 4:42 pm ] |
Post subject: | |
That's a nice lil quickie tutorial on for loops. Not to knock on your tutorial, or discourage you from sharing your knowledge, but this tutorial was already made, click! Next time, just take a gander through that "Turing Walkthrough" link, it's a sticky in the Tutorial section, and just see what tutorials haven't been done, or if you see any that can use some work. |
Author: | Cervantes [ Wed Mar 01, 2006 8:13 pm ] |
Post subject: | |
jamonathin wrote: Next time, just take a gander through that "<a href="http://www.compsci.ca/v2/viewtopic.php?t=8808">Turing Walkthrough</a>" link, it's a sticky in the Tutorial section, and just see what tutorials haven't been done, or if you see any that can use some work.
Actually, the Improving Tutorials topic would be the ideal place to get information on what tutorials need to be made. |
Author: | jamonathin [ Wed Mar 01, 2006 11:10 pm ] |
Post subject: | |
Cervantes wrote: jamonathin wrote: Next time, just take a gander through that "<a href="http://www.compsci.ca/v2/viewtopic.php?t=8808"><a href="http://www.compsci.ca/v2/viewtopic.php?t=8808">Turing Walkthrough</a></a>" link, it's a sticky in the Tutorial section, and just see what tutorials haven't been done, or if you see any that can use some work.
Actually, the Improving Tutorials topic would be the ideal place to get information on what tutorials need to be made. blah blah blah w/e |