Why is it the "for i" loop?

Home » Programming & Design » Why is it the "for i" loop?
Programming & Design No Comments

Like why is there an i in there. Who decided to make it like that and why?

Other answer:

Giselle:
It's older than FORTRAN, actually. Mathematics conventionally uses lowercase i, j, k, …, n as integer variables, particularly in sum and product notation. Think "i" for "integer" or "index" and "n" for "number", and the other letter were used similarly because they were close in the alphabet. Late letters (x,y,z mostly) were used for real variables, and early letters (a,b,c) were used for symbolic constants. So, the middle of the alphabet became home to integer variables.

When translating an algorithm from mathematical notation to a computer program, it's common to make the program as close to the original as is practical to aid in visually verifying that the program is correct.

FORTRAN based it's implicit variable types on that convention, one that engineers were familiar with already (even though computer programming was a New Thing.)

brilliant_moves:
Hi Giselle.
The loop would be a "for" loop. The "i" is just the variable name. I would need to see the rest of the code to see why "i" is used and not "x" or "a" or …
EddieJ:
Fortran variables that started with I thru N were automatically integers, so "i" became the most common index variable. Nested loops are often controlled with a "j" and a "k".
Christopher:
"I" is short for "iterator"
turley:
"I" is short for "iterator"
Emma:
"I" is short for "iterator"
Gray:
"I" is short for "iterator"
Morrison:
"I" is short for "iterator"
Adam:
"I" is short for "iterator"
Owen:
"I" is short for "iterator"

LEAVE A COMMENT