Whatever you choose, use the same index consistently in your code wherever it has the same meaning. For example, to walk through an array, you can use i
, jj
, kappa
, whatever, but always do it the same way everywhere:
for (i = 0; i < count; i++) ...
The best practice is to make this part of the loop look the same throughout your code (including consistently using count
as the limit), so that it becomes an idiom that you can skip over mentally in order to focus on the meat of the code, the body of the loop.
Similarly, if you're walking through an 2d array of pixels, for example, you might write
for (y = 0; y < height; y++)
for (x = 0; x < width; x++)
...
Just do it the same way in every place that you write this type of loop.
You want your readers to be able to ignore the boring setup and see the brilliance of what you're doing in the actual loop.