First of all let me say that this piece of code is terrible. If I ever encounter someone in real life that writes code like this I will punch his lights out
No seriously, using the (de)incrementor in such a way is asking for trouble.
Anyways what happens is this:
You start out with j=2. When the lab1 rule is encountered for the first time. j=2 and i=1 at the time of the
test so it succeeds. When the test is done the j value is upped by 1 so it's value becomes 3.
So in the lab2 rules at the time of the test the j=3, i=1 and k=0. So k < j and the test succeeds. j is reduced by one before continuing.
So when the j>k/i is executed it actually equals to this 2>0/1.
So the test passes and the lab1 loop is exited.
Resulting in a j == 2 value.
I hope you can follow me?
[ August 12, 2005: Message edited by: Manuel Moons ]