Computer Science Canada Counters and Accumulators |
Author: | Tallguy [ Fri Jun 01, 2007 8:25 am ] | ||||
Post subject: | Counters and Accumulators | ||||
Repetitive structures: Counters and Accumulators Counters OK. Most of you have been using counters since you started doing animation. When one needs to count how many times a program executes a loop (without using a counted loop), one uses a counter. Counters need two things in order to function: 1) an Initial Value, and; 2) an Incremental Value. The initial value is usually (but not always) zero, and must be located outside the loop. It tells the program what number to begin counting at. The incremental value, on the other hand, tells the program what to count by (one's usually, but it could be any number) and must be located inside the loop. Try this:
Try changing the increment from 1 to 2. What happens? Accumulators Accumulators are identical to counters with one difference. While they must have both an initial value and an incremental value; the incremental value is determined by a variable. Accumulators are used to keep a running total of numbers during successive passes through a loop. Try this:
|
Author: | DifinityRJ [ Fri Jun 01, 2007 10:50 am ] |
Post subject: | Re: Counters and Accumulators |
Did you get this passed by an admin to write this tutorial about counters and accumulators? |
Author: | Cervantes [ Fri Jun 01, 2007 6:49 pm ] |
Post subject: | RE:Counters and Accumulators |
Er, it's not that we require that you get your tutorial approved before posting, but rather that if you're serious about making a tutorial, we appreciate it if you send it to us first so we can help out and offer advice. There's a lot involved in writing quality tutorials. I don't really think this topic needs a tutorial, though. It's not a special kind of syntax, and it's a not mind bending language concept, and it's not a difficult algorithm. I've cleaned the post up a bit so now it has code tags, and some minor headers. |
Author: | Tallguy [ Sat Jun 02, 2007 3:37 pm ] |
Post subject: | RE:Counters and Accumulators |
srry for not running it by u first, thanks for fixing the mistakes i made |
Author: | DaveAngus [ Tue Mar 18, 2008 9:22 am ] |
Post subject: | RE:Counters and Accumulators |
Yea this is a pretty easy concept. Not to sure why theres a tutorial. But...then again... we were all in a starting position in this program and sometimes you need to learn the basics. Thanks for posting! |