AFAIK using i in loops stems back to the early days of Fortran (late 1950's) where variables i j k l m n were integer variables by default. The other letters were real numbers.
Using i for a loop variable is a throwback to the early FORTRAN days when the first letter of your variable determined it's type.
Here are some situations where you don't want to use i as a loop variable.
1) Nested loops.
2) When the loop variable represents something obvious like a row or column.
3) When you use std containers such as std::vector, you will probably want to use something more specific such as iter to indicate the loop variable is an iterator.
4) When using the keyword auto, You will want your loop variable to represent an object of the iteration.
I don't, because I prefer every variable name to self-document what I'm doing.
For example: for (size_t loop_itr { }; loop_itr < max_value; ++loop_itr)
loop_itr self-documents what the variable is doing. At least to me; hopefully it informs others who read the source as well.
There is no requirement in the standard what a loop's incrementing variable must be named, but there is the long standing tradition of using i (or other single letter variable names ) for the variable.
If you were told it is a requirement that person lied to you.
> There is no requirement in the standard what a loop's incrementing variable must be named,
> but there is the long standing tradition of using i
Most often, the variable involved is of an integer type: for example, an index into an array.
The scopes of names declared in the init-statement (or the condition) of a for loop is usually very small.
Kernighan and Pike in 'The Practice of Programming'
By contrast, shorter names suffice for local variables; within a function, n may be sufficient, npoints is fine, and numberofPoints is overkill.
Local variables used in conventional ways can have very short names. The use of i and j for loop indices ... is so frequent that there is little profit and perhaps some loss in longer names. ...
Programmers are often encouraged to use long variable names regardless of context.
That is a mistake: clarity is often achieved through brevity.
Where the variable involved is not an integer loop index, we wouldn't (shouldn't) use the name i for it.
For example, these are all fairly conventional for loops:
It's just a traditional way to write code as we started learning like that but it is not necessary to use 'i' in for loop you can use other variables too