Search Icon, Magnifying Glass

Marmanold.com

Graduation Cap Heart Question Mark Magnifying Glass

The Magic Variable 'count'

So, I happened to be looking back through some old files and I found an early programming assignment from my first computer science course back in college. In the middle of the code I found this wonderful line:

while (cownt<years) {
    cout<<cownt+1; //"cownt" = "count", but when I entered it spelt correctly it gave me errors.//

As it turns out early on in the code I declared int cownt=0;. I either couldn’t find this typo in debugging my mere 61 lines of code or — what I think was actually going on — I thought count was a reserved magical variable that made loops work — not something I had to declare. Sometimes it’s nice to look back and see how far you’ve come.