# I++? i--? why the "i"?

**URL:** <https://forum.kirupa.com/t/i-i-why-the-i/111602>\
**Category:** Uncategorized\
**Created:** [May 28, 2004, 7:09pm UTC](https://forum.kirupa.com/t/i-i-why-the-i/111602 "2004-05-28T19:09:55Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![jarviscares](https://avatars.discourse-cdn.com/v4/letter/j/8e7dd6/32.png) [@jarviscares](https://forum.kirupa.com/u/jarviscares)\
**Post date:** [May 28, 2004, 7:09pm UTC](https://forum.kirupa.com/t/i-i-why-the-i/111602/1 "2004-05-28T19:09:55Z")

</div>

hmm… this isnt’ really a question about any particular problems i’m having, just kind of a more “why?” question…

i always see examples of code for instance:  
[As]  
if (i\>5)  
{  
i++;  
}  
else  
{  
i–;  
}  
[/As]  
just wondering why “i” is always used… could you use “a”? or “q”? or “fuzzy”? or any other variable? or is it proper syntax to use “i” and won’t work without it? or just simply good coding practice… or just a "generic “insert your variable here”… or just one of those mysteries nobody will ever know…

hopefully one of you gurus out there can help a relative beginner like me move one step closer to the understanding of actionscript and coding in general!

much appreciated,  
-Jarviscares

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 28, 2004, 7:12pm UTC](https://forum.kirupa.com/t/i-i-why-the-i/111602/2 "2004-05-28T19:12:00Z")

</div>

‘i’ is usually used just because it is a convention in programming. you could rightly use any letter you want… although i would not recomment you use words. single letters are pretty much the way to go.

sam

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 28, 2004, 7:33pm UTC](https://forum.kirupa.com/t/i-i-why-the-i/111602/3 "2004-05-28T19:33:14Z")

</div>

i think i stands for iteration, but i am not tottaly sure. you can use anything that is not a reserved word.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 28, 2004, 7:50pm UTC](https://forum.kirupa.com/t/i-i-why-the-i/111602/4 "2004-05-28T19:50:27Z")

</div>

In the classic text ‘The C Programming Language’ by Kernighan and Ritchie, _i_ is commonly used as a loop variable. I got into the habit of using _i_ when I was first learning C from this book (back in the 80s), and I imagine a lot of other old coders did too. Old habits die hard. K&R is the same book that popularized the classic ‘hello world’ program and a number of other coding memes, still in use today in C-like languages.

Prior to learning C, I did a lot of BASIC programming, and I used to use _x_ a lot of my loops. _x_ being the classic variable name from my high school algebra class. I still sometimes use x & y, particular if I am looping on coordinates in 2-d space, but for a single loop I will tend to use _i_, leaving x & y free for other uses.

I’ve occasionally written 3-way nested loops using i, j and k. My GAWD I’m a nerd.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 28, 2004, 8:05pm UTC](https://forum.kirupa.com/t/i-i-why-the-i/111602/5 "2004-05-28T20:05:25Z")

</div>

awesome, thanks for the quick replies! exactly what i was looking for. man this forum rocks :love:

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 28, 2004, 8:33pm UTC](https://forum.kirupa.com/t/i-i-why-the-i/111602/6 "2004-05-28T20:33:51Z")

</div>

i always used x for all for loops

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 28, 2004, 11:27pm UTC](https://forum.kirupa.com/t/i-i-why-the-i/111602/7 "2004-05-28T23:27:05Z")

</div>

i stands for index.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 29, 2004, 12:45am UTC](https://forum.kirupa.com/t/i-i-why-the-i/111602/8 "2004-05-29T00:45:04Z")

</div>

\<Offtopic\>  
Jbum, your flash experiments are amazing. Where did you learn to do all of that stuff? Was it just trial and error? Are you just a genious?

–You should enter an actionScript battle sometime hehe 😉  
\</Offtopic\>

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 29, 2004, 3:42am UTC](https://forum.kirupa.com/t/i-i-why-the-i/111602/9 "2004-05-29T03:42:22Z")

</div>

> [@Yeldarb](#):
>
> \<Offtopic\>  
> Jbum, your flash experiments are amazing. Where did you learn to do all of that stuff? Was it just trial and error? Are you just a genious?
> 
> –You should enter an actionScript battle sometime hehe 😉  
> \</Offtopic\>

holy crap lol… im amazed 🙂

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 29, 2004, 3:46am UTC](https://forum.kirupa.com/t/i-i-why-the-i/111602/10 "2004-05-29T03:46:29Z")

</div>

Easy-E

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 29, 2004, 7:56am UTC](https://forum.kirupa.com/t/i-i-why-the-i/111602/11 "2004-05-29T07:56:23Z")

</div>

I think “i” was around when one could only have a certain amount of variables in a program, way back in like cobol of fortran, or something. “i” “j” “k” I think up to “p” were used for in loop guards and counters, other letters were used for different types of variables. Yeah, as you nest more loops you tend to to up the alphabet from “i”.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 29, 2004, 8:26am UTC](https://forum.kirupa.com/t/i-i-why-the-i/111602/12 "2004-05-29T08:26:10Z")

</div>

It stems from Fortran. In Fortran, you can declare your variables if you want to, but if you don’t they get a default declaration based on the first letter of the variable name.

Variables that start with I through N are integers and all others are reals. So if you needed a loop variable, you started with ‘i’. For the next one you took ‘j’ and so on.

And then it just stuck…

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 29, 2004, 9:08am UTC](https://forum.kirupa.com/t/i-i-why-the-i/111602/13 "2004-05-29T09:08:33Z")

</div>

Very interesting 🙂 You know, I think that the use of _i_ comes from mathematics. _i_ is used in demonstrations (?? when you’re trying to prove a theorem) in substitution to any integer. Just as _n_ is traditionally the last one of those integers.

In algebra, for instance, if you take a one-dimensionnal matrix, it’s going to be written [a1, a2, …, ai, …, an].

My 2 cents =)

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 29, 2004, 10:51am UTC](https://forum.kirupa.com/t/i-i-why-the-i/111602/14 "2004-05-29T10:51:02Z")

</div>

You’re probably right, Ilyas, that the developers of Fortran took the default declaration stuff from mathematics. In the early days computers were mostly used for number crunching and many of the people working with computers had a background in mathematics.

Funny how something like that evolves and sticks around to this day.

Reminds me of the story about how some parts of the space shuttle were the same size as two horse are wide: [http://www.astrodigital.org/space/stshorse.html](http://www.astrodigital.org/space/stshorse.html).

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 30, 2004, 5:16am UTC](https://forum.kirupa.com/t/i-i-why-the-i/111602/15 "2004-05-30T05:16:33Z")

</div>

i _does_ stand for iteration. check out the reference. its what the macromedia ppls thought would be good for looping, but i guess according to someother dude who posted it was used for C first.
