When I look at a statement, how can i tell whether it's an accumulator or a counter?

Recommended Answers

All 4 Replies

Please give an example. An accumulator will generally add several numbers to it. A counter adds one.

Thank you! You've answered my question. I thought a counter could add more than one.

The qualifier is "generally". No hard and fast rule.

'Loop allows for a repitition of statements - using a condition to decide when the loop should continue or stop
'There are 2 main concepts that come into loops;
'1 - Incrementing - counter = counter + 1 -- always by a constant (in this case '1')
'2 - Accumulating - totalsales = totalsales + sales -- always by a variable (in this case 'sales')

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.