0

Possible Duplicate:
Why are variables “i” and “j” used for counters?

Maybe a stupid unmeaningful question, but I'm just curious.

The 'i' variable probably denotes a shortcut for 'index' or 'iterator' and it seems common sense to call it like that.

I tried googling a bit about it, to try to find some indication that somebody cleaver in the early stage of programming denoted this as a 'convention' for an 'sporadic' iterator variable name, and others started using it.

However did not find anything...

Possibly the world of early programmers came to this convention by common sense and it become a defacto standard nowadays?

Community
  • 1
  • 1
Marino Šimić
  • 7,256
  • 1
  • 27
  • 59

2 Answers2

1

Actually, it comes from FORTRAN, by way of mathematics. In the original FORTRAN dialects, variable names starting with I, J, K, L, M, or N (maybe a few more) were implicitly integers; other names were implicitly reals. It therefore just made sense to use "I" as that index. Furthermore, there's a long tradition of using i, j, k as matrix indices in mathematics; FORTAN, short for formula translator, was often used to implement mathematical formulas, and so you'd use those same I, J, K for your matrices.

Ernest Friedman-Hill
  • 79,064
  • 10
  • 147
  • 183
1

It probably goes back to the days of FORTRAN when integer variables had to start with I, J, K or L

Given that limitation, I was a logical choice for a simple loop variable.

pavium
  • 14,290
  • 4
  • 30
  • 46