+ 2

Why we write 'i' in For loop??

15th Mar 2020, 4:04 PM
Md Faijan Ahmad
Md Faijan Ahmad - avatar
17 Answers
+ 4
i == iterator or index My understanding has always been 'i' is a good choice since loops are typically for iterating or traversing with a known index step. The letters 'j' and 'k' follow well since nested loops are often needed and most will instinctively know 'j' == second index and 'k' == third index since they follow that pattern in the alphabet. Additionally, with many following this standard convention, one can safely assume a 'k' loop will likely have a 'j' and 'i' loops wrapping it. i is just variable it is mostly used in for
16th Mar 2020, 4:35 AM
Ishan Shah
Ishan Shah - avatar
+ 10
i is just variable like int i, int j, int k. You can use anything in loop like for(int j = 0; j < 10; j++) { } It is not necessary to use only i.
15th Mar 2020, 4:05 PM
A͢J
A͢J - avatar
+ 5
It's just a variable that assumes the values of the elements of an iterable object. Probably because generally we use for loop to iterate over arrays where "I" represents "index" of a value
15th Mar 2020, 4:07 PM
Arsenic
Arsenic - avatar
+ 5
It is not necessary we can use what we want general I represents the starting letter of index
16th Mar 2020, 5:57 AM
Teja
Teja - avatar
+ 5
It is just variable we can use anything as a variable in for loop
17th Mar 2020, 2:35 AM
Neetesh Koli
+ 3
i is just a variable. there's nothing special
15th Mar 2020, 8:35 PM
Mitraj Gohil
Mitraj Gohil - avatar
+ 3
Normally when we are writing loops conditions in programming we used to use i j k like variable.that is not a standard. as well as if we are doing a project with proper coding styles that are not good. always try to initialize a variable with a proper meaningful name.it will help to debug the program easily.
16th Mar 2020, 6:18 AM
Chathura Janaranjana Wanniarachchi
Chathura Janaranjana Wanniarachchi - avatar
+ 2
It is common practice to use i in for loops. This is just what programmers are used to.
16th Mar 2020, 11:56 AM
Mohamad Nour Alaref
Mohamad Nour Alaref - avatar
+ 2
It may relate to the concept of dimension in 3D space in mathematics. The 3 mutual orthogonal unit vectors i, j and k represent the row, column and depth of a 3D array.
16th Mar 2020, 7:01 PM
Gareth
Gareth - avatar
+ 2
Its not actually that we always write i in for loop i is actually a variable and you can have any variable any character or string i is commonly used , that's true but you can use any variable
17th Mar 2020, 6:08 AM
Suparno Saha
Suparno Saha - avatar
+ 1
because we didn't use w
17th Mar 2020, 2:07 AM
l4t3nc1
l4t3nc1 - avatar
+ 1
u can use item or things
17th Mar 2020, 4:14 AM
Carl Wheezer
Carl Wheezer - avatar
+ 1
It's an iterative variable we can use any other valid one
17th Mar 2020, 9:27 AM
Bamanna T Bamgonde
+ 1
We use "i" for the purpose of iteration , its just a general practice to use the letter "i" you can use whatever you like for example x, y, z, alpha, beta, gamma, etc.
17th Mar 2020, 2:12 PM
Aditya Jetely
Aditya Jetely - avatar
0
I is use to drive for loop
17th Mar 2020, 8:41 AM
Sarfraz Ali
Sarfraz Ali - avatar
0
I is just the variable You can use others But it's famous because its symbolises iterative
17th Mar 2020, 9:30 AM
Ira Sarkar
Ira Sarkar - avatar
0
It is just a variable, you can use any word or letter of your choice
17th Mar 2020, 6:53 PM
Ayooluwa Aduwo
Ayooluwa Aduwo - avatar