A counter is a variable that keeps track of a value, usually used to count or iterate through a loop.
Think of a counter as a scoreboard in a basketball game. It starts at 0 and every time someone scores, the score increases by 1. The counter keeps track of the total number of points scored.
Increment: Incrementing means increasing the value of something by a specific amount. For example, if you increment a counter by 1, its value will increase by 1.
Loop: A loop is a programming construct that allows you to repeat a set of instructions multiple times. Counters are often used in loops to control how many times the loop should run.
Variable: A variable is a named storage location in computer memory that can hold different values during program execution. Counters are typically implemented as variables.
Study guides for the entire semester
200k practice questions
Glossary of 50k key terms - memorize important vocab
© 2024 Fiveable Inc. All rights reserved.
AP® and SAT® are trademarks registered by the College Board, which is not affiliated with, and does not endorse this website.