You could always try
for( i=0;i<20;i++)
and observe the error messages
Maybe then try int i;
for(i=0;i<20;i++)
Salem
Posting Sage
11,531 posts since Dec 2005
Reputation Points: 5,862
Solved Threads: 953
Why the hell is there an i, does it means something, it's just an easy way to remember something or what?.
Relax and read some Wikipedia -> loop counter
FYI. If you don't like (too) short variable names, you are free to pick your poison. I think, C++ standard recommends that an identifier would be allowed to be 1024 characters long (the minimum).
mitrmkar
Posting Virtuoso
1,809 posts since Nov 2007
Reputation Points: 1,105
Solved Threads: 395
I believe that 'i' is used in accordance with the rules of Hungarian Notion; a coding style used to self identify the type variables (int type vars use 'i').
Check out Hungarian Notation.
Clinton Portis
Practically a Posting Shark
833 posts since Oct 2005
Reputation Points: 237
Solved Threads: 118
I believe that 'i' is used in accordance with the rules of Hungarian Notion; a coding style used to self identify the type variables (int type vars use 'i').
Check out Hungarian Notation.
Nope.i has been used long before Hungarian Notation.
From Wikipedia:
"The original Hungarian notation, which would now be called Apps Hungarian, was invented by Charles Simonyi, a programmer who worked at Xerox PARC circa 1972-1981, and who later became Chief Architect at Microsoft. It may have been derived from the earlier principle of using the first letter of a variable name to set its type — for example, variables whose names started with letters I through N in FORTRAN were integers by default."
WaltP
Posting Sage w/ dash of thyme
10,505 posts since May 2006
Reputation Points: 3,348
Solved Threads: 944
One of the first real fortran program every written was about the gamma function, and in typical mathematical notation it evaluated [tex]\sum_{i=1}^{6} \frac{\gamma_i}{1+\lambda_i \tau}[/tex] ina typical math function. Unfortunately I haven't seen the original code for it. But the use if i,j,... etc is extremely common for subscript in maths notation, so given that it was mathematicians that were the originators of computing, their notation become standard were it is applicable.
However, the first fortran compile manual [IBM 704] (published in 1956), uses i as a loop variable in the very first program (finding the largest number in a set).
StuXYZ
Practically a Master Poster
680 posts since Nov 2008
Reputation Points: 760
Solved Threads: 138
i is used probably because it stands for iteration. People choose to use it because i is short and it looks clean when you use it as an array index (compare array[i] to array[numloops]).
Tumlee
Junior Poster in Training
97 posts since Oct 2011
Reputation Points: 59
Solved Threads: 16