[ACCEPTED]-Who "invented" i,j,k as integer counter variable names?-loop-counter
i = integer
Comes from Fortran where integer 10 variables had to start with the letters 9 I through N and real variables started with 8 the other letters. Thus I was the first 7 and shortest integer variable name. Fortran 6 was one of the earliest programming languages 5 in widespread use and the habits developed 4 by programmers using it carried over to 3 other languages.
(From: Why are we using i as a counter in loops)
Obviously, j
and 2 k
are just the next ones in your favorite 1 alphabet.
The Mathematicians :)
0
It's common from school-level and college-level 10 algebra exercises (although x
and y
had their 9 part to play, there, too :-)
Also, if I remember 8 correctly, the early programming languages 7 (like early versions of FORTRAN
) used variable 6 naming in a way where initial letters were 5 significant, and this may have had a part 4 to play. For example, as this page says:
A FORTRAN 3 variable is a way of referring to a cell 2 of the computer. Names for variables must 1 conform to the following rules:
- The name may be from one to six characters.
- The first character must be a letter.
- Characters other than the first may be letters or numeric digits.
- If the first character is I, J, K, L, M or N, the variable is integer (i.e. can hold a whole number value). Otherwise, it is real (i.e. can hold a value according to the floating point convention).
FORTRAN. If the first character is I, J, K, L, M 4 or N, the variable is integer (i.e. can 3 hold a whole number value). Otherwise, it 2 is real (i.e. can hold a value according 1 to the floating point convention).
I always thought i stands for index as used 1 eg in sum formulas in mathematics.
From the wikipedia for Loop Counter
A common identifier 14 naming convention is for the loop counter 13 to use the variable names i, j and k (and 12 so on if needed), where i would be the 11 most outer loop, j the next inner loop, etc. The 10 reverse order is also used by some programmers. This 9 style is generally agreed to have originated from 8 the early programming of FORTRAN, where 7 these variable names beginning with these 6 letters were implicitly declared as having 5 an integer type, and so were obvious choices 4 for loop counters that were only temporarily required. The 3 practice also dates back further to mathematical 2 notation where indices for sums and multiplications are 1 often i, j, etc.
More Related questions
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.