QUOTE(Thegnome @ 13 Apr, 2008 - 08:49 AM)

Yeah, well I am not quite sure what you mean by should NEVER have their variable manipulated outside the declaration, well I kinda get it.
The reason is, the "for" loop defines all three mechanisms of a loop in one place: initial counter, continue looping condition, and incrementor. You can manipulate the declaration to do other things, but that's really the point of it.
The little mess you have here would actually be better served by a while loop, you'll be able to see what's going on clearer. Remember, a for loop can always be expressed in a while loop ( and the other way around, which is kind of messy and basically what you have here. )
So this:
CODE
for (int q = 2; q < 32; q = q * 2) {
//...
}
Can be this:
CODE
int q = 2
while(q < 32) {
//...
q = q * 2
}
Now, let's comment the loop one more time, only use the while to help clarify ( because we can print the exit condition):
CODE
int loopCount = 0;
int p = 2;
int q = 2;
while(q < 32) {
// we increment our counter here, it will always start with 1
loopCount++;
Console.WriteLine(loopCount + "\tq = \t"+q);
Console.WriteLine(loopCount + "\t(p < q)\t"+(p < q));
while (p < q) {
p = p * 2;
Console.WriteLine(loopCount + "\t(p * 2)\t"+p);
}
q = p - q;
Console.WriteLine(loopCount + "\t(p - q)\t"+q);
q = q * 2;
Console.WriteLine(loopCount + "\t(q * 2)\t"+q);
Console.WriteLine(loopCount + "\t(q < 32)\t"+(q < 32));
Console.WriteLine("");
}
CODE
1 q = 2
1 (p < q) false
1 (p - q) 0
1 (q * 2) 0
1 (q < 32) true
2 q = 0
2 (p < q) false
2 (p - q) 2
2 (q * 2) 4
2 (q < 32) true
3 q = 4
3 (p < q) true
3 (p * 2) 4
3 (p - q) 0
3 (q * 2) 0
3 (q < 32) true
4 q = 0
4 (p < q) false
4 (p - q) 4
4 (q * 2) 8
4 (q < 32) true
5 q = 8
5 (p < q) true
5 (p * 2) 8
5 (p - q) 0
5 (q * 2) 0
5 (q < 32) true
6 q = 0
6 (p < q) false
6 (p - q) 8
6 (q * 2) 16
6 (q < 32) true
7 q = 16
7 (p < q) true
7 (p * 2) 16
7 (p - q) 0
7 (q * 2) 0
7 (q < 32) true
8 q = 0
8 (p < q) false
8 (p - q) 16
8 (q * 2) 32
8 (q < 32) false
It occurs to me that even this could be a little clearer. Play around with it if you like. Commenting code you don't follow is a very good habit to be in.
Good luck