+ 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?

9th Feb 2017, 7:49 AM
hs k
hs k - avatar
45 Answers
+ 29
I think it's for "index"
9th Feb 2017, 1:45 PM
C.E.
C.E. - avatar
+ 24
iteration, most probably.
9th Feb 2017, 7:51 AM
Kuba Siekierzyński
Kuba Siekierzyński - avatar
+ 17
Norms, just like 'x' and 'y' or 'a' and 'b' being used in algebra expressions.
9th Feb 2017, 8:10 AM
Hatsy Rei
Hatsy Rei - avatar
+ 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)
9th Feb 2017, 5:35 PM
Kirk Schafer
Kirk Schafer - avatar
+ 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.
11th Feb 2017, 4:32 AM
Mayur Garg
Mayur Garg - avatar
+ 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... ^^-^^
10th Feb 2017, 9:15 AM
Femyk
Femyk - avatar
+ 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
13th Feb 2017, 6:29 AM
Dean Hayes
Dean Hayes - avatar
+ 5
They are well established convention😉
9th Feb 2017, 7:53 AM
Samuel Kurnas
+ 4
It comes ultimately from mathematics: the summation notation traditionally uses i for the first index, j for the second, and so on.
11th Feb 2017, 7:21 PM
Kunal Lachuriye
Kunal Lachuriye - avatar
+ 3
It looks good to use "i" but You can use many others... Thank You
14th Feb 2017, 3:54 PM
Ritesh Patel
Ritesh Patel - avatar
+ 2
i has typically been used as subscript in quite a bit of math for quite some time
9th Feb 2017, 3:33 PM
George Georgopoulos
George Georgopoulos - avatar
+ 2
there is no condition. u can u different letters also
11th Feb 2017, 2:55 PM
saif ali
saif ali - avatar
+ 2
it looks like easy to suddenly understand for our mind
12th Feb 2017, 6:00 PM
desi code
desi code - avatar
+ 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
13th Feb 2017, 7:00 PM
Siddharth Upadhyay
Siddharth Upadhyay - avatar
+ 2
i is for integer, or int I guess
14th Feb 2017, 7:26 AM
Daniel Fernandes
Daniel Fernandes - avatar
+ 2
because the first programmer wrote it that way, and all the programmers ever after were lazy to think about a new name.
14th Feb 2017, 9:01 AM
Shahar Levy
Shahar Levy - avatar
+ 1
Most programmers tend to keep letters a-h for declaring variables,so the next choice is i,j for looping.
10th Feb 2017, 12:44 PM
decoder
decoder - avatar
+ 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.
12th Feb 2017, 2:07 AM
Chad Mitchell
Chad Mitchell - avatar
+ 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)
14th Feb 2017, 1:32 AM
Noulmon K C
Noulmon K C - avatar
+ 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.
14th Feb 2017, 7:29 AM
mukesh suthar