Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Who "invented" i,j,k as integer counter variable names? [duplicate]

Possible Duplicate:
Why are we using i as a counter in loops

I've used these myself for more than 15 years but cannot really remember how/where I picked up that habit. As it is really widespread, I'm curious to know who originally suggested / recommended using these names for integer loop counters (was it the K&R book?).

like image 279
mjy Avatar asked Nov 28 '22 05:11

mjy


1 Answers

i = integer

Comes from Fortran where integer variables had to start with the letters I through N and real variables started with the other letters. Thus I was the first and shortest integer variable name. Fortran was one of the earliest programming languages in widespread use and the habits developed by programmers using it carried over to other languages.

(From: Why are we using i as a counter in loops)

Obviously, j and k are just the next ones in your favorite alphabet.

like image 81
Reunanen Avatar answered Dec 10 '22 05:12

Reunanen