English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

4 answers

i is a variable and i++ means it just adds one to itself when it is called.

2006-10-08 11:34:28 · answer #1 · answered by uscmedguy 3 · 0 0

There is nothing special about the variable "i", "i" in itself is just a name pulled out of a hat like "foo". You could just as easily use "n" or "x" as long as you don't interfere with values another part of your code is expecting.

The ++ operator is the "auto-increment" operator. By themselves, the following three statements are equivalent:

i = i + 1;
i += 1;
i++;

However, if you are using the value of "i++" in a statement, you fetch the current value of i and it gets incremented behind your back. In this snippet,

i = 5;
x = i++;
y = i;

x is left with 5 and y is left with 6.

"++i" does the opposite; i is incremented first, so with this:

i = 5;
x = ++i;
y = i;

x and y are both 6.

i-- and --i behave the same way, except that they decrease i by 1.

2006-10-08 12:13:51 · answer #2 · answered by G. Whilikers 7 · 0 0

er. "i" is a variable and "++" means increment itself by one.
so
i++ can be rewritten as i+=1 or i=1+i

I don't know what you mean the "other uses of i" because "i" in this case is just an example variable... and you can do anything you want with a variable...

2006-10-08 10:56:22 · answer #3 · answered by Robin C 4 · 1 0

"i++" means to increment "i" in your program, so "i" must be in your program as a counter of some kind...

the other uses of "i" must be for checking to see if other conditions are met or not...

it would help if you would post the "other" uses.

2006-10-08 11:46:42 · answer #4 · answered by ♥Tom♥ 6 · 0 0

fedest.com, questions and answers