+ 3

Why is i and j used in for loops?

23rd Mar 2021, 10:59 AM
Ù…Ű­Ù…ŰŻ Ű§Ù„ŰŽŰ§ÙˆŰŽ
Ù…Ű­Ù…ŰŻ Ű§Ù„ŰŽŰ§ÙˆŰŽ - avatar
10 Respostas
+ 7
i and j are not mandatory... however, as they often hold indexes of an array, that's common to use i (wich could also mean 'iteration')... inner loops then receive usually next letters: j, k... other commonly variable names used in loops could be x (as frequently used in math variable, with y then z), or even v (when used in for...in/of loops, where the variable would better mean 'value', with t, u). by the way, you could use 'the_counter_of_my_loop' if you want so... but you must need to type that long name everywhere you use it ^^ usually it's advised to use meaningful names for variables/functions, but for loop counters are often used only inside the loop, so it's implicitly allowed to have very short names in these cases)
23rd Mar 2021, 11:25 AM
visph
visph - avatar
+ 5
Every programming language have some sort of rules to follow. Fewer example including camel case naming conventions( java), in c# variable name should start with capital letters, four spaces for indentation in Python and many more. You're completely independent to do whatever you want, but not following this simple terms will make your code different from others, perhaps more complex to grasp. this are not rules but responsibility for a programmer. Generally the i in for loops stands for iterator, that's why most of programmers use i instead of other names.
23rd Mar 2021, 4:02 PM
0_O-[MĂ€gĂĄr_SĂĄm_ÄkĂ _NĂŒllpÞïntĂȘr_ÈxĂ«cĂ©ptïön]~~
0_O-[MĂ€gĂĄr_SĂĄm_ÄkĂ _NĂŒllpÞïntĂȘr_ÈxĂ«cĂ©ptïön]~~ - avatar
+ 2
i for index or integer
23rd Mar 2021, 11:28 AM
zemiak
+ 2
They are just name of variables you can choose whatever you want😊
23rd Mar 2021, 7:37 PM
Adil Khan
Adil Khan - avatar
+ 2
I-short of word - iteration , j-next short simbol in alfabet after i
24th Mar 2021, 7:57 PM
Rustem Gabitov
Rustem Gabitov - avatar
+ 2
I'm new in here limit help me learn
25th Mar 2021, 12:33 AM
Salaheddine Abbas
Salaheddine Abbas - avatar
+ 2
Variables starting with I through Q were integer by default, the others were real. This meant that I was the first integer variable, and J the second, etc., so they fell towards use in loops
25th Mar 2021, 2:22 AM
Shifu
Shifu - avatar
+ 2
i and j are just a variable name, you can use any variable name like a, b, c,x, y or number, length etc. i, j, k is probably preferred because they are short so fast to write in codes & commonly used by codes or courses we commonly see, so we also start using them.
25th Mar 2021, 3:11 AM
Bot
Bot - avatar
+ 2
for my opinions a lot of leaners use them because they find them in many examples of loops while they are studyng fundamentals or introductions in programming and they grow with them . so its a tendency. These days i use 'a' and 'b' as variables name to make sure that students are not creaming.
25th Mar 2021, 8:57 AM
Ona Nixon đŸ‡č🇿 👑
Ona Nixon  đŸ‡č🇿  👑 - avatar
+ 2
I would say because i and j are used commonly as indices in Linear Algebra.
25th Mar 2021, 11:08 AM
Sonic
Sonic - avatar