Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Possible Duplicate:
Why do most of us use 'i' as a loop counter variable?

Maybe this questions seems to be extreamly stupid but I wonder why we use i as variable in most cases in for loops (and not other letter). This might be a historical cause.


for(int i = 0; i < 10; i++)
share|improve this question

migrated from Aug 19 '11 at 13:51

This question came from our site for professional and enthusiast programmers.

marked as duplicate by Adam Lear Aug 19 '11 at 14:15

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

In my O'Reilly ABC book, i is for int – James Aug 19 '11 at 13:50
By the way, I prefer ++i to i++ ;-) – fredoverflow Aug 19 '11 at 14:53
I prefer to use me – CamelBlues Aug 19 '11 at 18:02

Long ago there was a programming language called FORTRAN, indeed the first so called higher programming language. In FORTRAN variables names beginning with i,j,k,l,m,n were implicitly declared of type INTEGER. So i can stand for:

  • integer
  • index (of an array, like in a[i])

or other things. Short names are typed quickly, so i is a good choice for a loop counter.

The FORTRAN convention goes deeper. Mathematicians love to name integer variables i,j,k,l,m, or n. They often use a,b,c,d,e,f for constant values and x,y,z for variables.

share|improve this answer

In FORTRAN IV, the variable names I-N were implicitly assumed to be integers. I think it's part of FORTRAN's legacy as a scientific computing language. Linear algebra uses integer indexes to derefence values in vectors and matricies. The convention diffused into other languages.

share|improve this answer

I guess the i stands for index.

Long ago, when computers were not that fast and memory and storage space was expensive, it was important to keep your source code small, so that it would fit in memory and the compilation process would run faster. Those things are not true anymore with today's computers, but still the i as the first index variable name stuck.

share|improve this answer

For what it's worth, I never use i. Perhaps this is a byproduct of using simpler text-editors, rather than IDEs, but I find it makes it very difficult to scan through a routine looking for places where the variable is used. To see what I mean, try searching for all the places i exists on this page, and seeing which ones refer to it as a variable, and which are incidental.

I always use more meaningful names, like

for(int Index = 0; Index < 10; Index++)
    // do something
share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.