+ 13
Why do books and people normally use 'i' for 'for statement'?
i just wonder why books and people normally use 'i' for 'for statement'. And j or k for the second and third. what does 'i' stand for?
45 Answers
+ 29
I think it's for "index"
+ 24
iteration, most probably.
+ 17
Norms, just like 'x' and 'y' or 'a' and 'b' being used in algebra expressions.
+ 16
a(i,j) is used by convention to iterate a (m x n) matrix (2D array) where i iterates (m:rows), j iterates (n:columns), and k iterates (o:depth, if present).
A 1D array is like a 1-column vector (or just data with an "i"ndex).
Infographic + explanation: https://en.m.wikipedia.org/wiki/Matrix_(mathematics)
... debut into programming, Fortran:
http://softwareengineering.stackexchange.com/a/86911
(also reveals why: x,y,z is for floating point)
+ 11
Your answer in one word - Convention
Using convention in education allows a uniform expression to be used everywhere so that it can be understood by everyone without a new separate explanation everytime.
+ 8
The syntax of the "for loop" in most programming languages is:
for(initial; final; iteration){}
If we check well, of the three conditions, the first and last begins with "i" ("I"nitial & "I"teration) and the other still has "i" stressed in it (f"i"nal).
This was the answer I came up with when I a asked myself sometime ago...
^^-^^
+ 8
It goes back to FORTRAN which didn't require you to declare all variables before using them. Variables starting with I, J, K, L, & N were implicitly defined to be integers. Being lazy and the fact the 'DO' loops index variable was required to be an integer, we always started with I
The first programmers using C and Pascal started with
has FORTRAN as their first language and old habits were carried forward and now it's a convento
+ 5
They are well established convention😉
+ 4
It comes ultimately from mathematics:
the summation notation traditionally
uses i for the first index, j for the
second, and so on.
+ 3
It looks good to use "i" but You can use many others... Thank You
+ 2
i has typically been used as subscript in quite a bit of math for quite some time
+ 2
there is no condition. u can u different letters also
+ 2
it looks like easy to suddenly understand for our mind
+ 2
because as we know that for loop consist of three parts
1. Initialisation
2. Iteration
3. Inspection
so having three I, s in the loop so mostly I is preferred
+ 2
i is for integer, or int I guess
+ 2
because the first programmer wrote it that way, and all the programmers ever after were lazy to think about a new name.
+ 1
Most programmers tend to keep letters a-h for declaring variables,so the next choice is i,j for looping.
+ 1
consistency. when you have lots of different classes using a universal index of I makes it easy for you and other programmers to understand.
+ 1
I think there is nothing special with 'i'. It's been used so it is used.You can you any alphabet(unless it is already used)
+ 1
programming logics are closely related with mathematics... and here the for loop variables are assumed as vectors or metrics thus I,j and k are taken as default notation from these.