oh ok so its the for loop at the end not the do while loop?
a for loop is declared like this:
1 2 3 4
|
for(initializtion; expression; increment)
{
//code...
}
|
so how this is read:
the initialization part is equivalent to:
int i = 0;
while(i < 10) ...
so in a for loop you would see this as:
for(int i = 10; ...
the expression part is the same as a while loop, so in this case, i < 10.
so now we have:
for(int i = 0; i < 10...
the increment part is equivalent to:
while(i < 10)
i = i + 1;
so now we have:
for(int i = 0; i < 10; i = i + 1)
{
//code...
}
*note: i declared the int i in the for loop, and while this is legal, doesnt need to be done.
ie: int counter;
for(counter = 0...
**note: how it is executed:
it first does the initialization, then checks to make sure the expression is true, then does the code, then does the increment, then (until the expression isn't true), checks the expression, then executes the code, then does the increment