Byte, Int, For Loop, and 0

for (byte k = 255; k >= 0; k--) {
//do stuff
}

This for loop runs forever, because on the last iteration as k = 0, the k-- wraps it around back to 255 and k is always >= 0. Using int works fine, I have no problem with using it, this is more of a learning opportunity kind of question.

I remember from C that using a do...while puts the //do stuff before the condition check, but can someone explain to me what happens if using byte in an equivalent do...while? Would the variable still get the wraparound (i.e., would it never fail condition check the same way the for loop does) or would it end on its own?

what happens if using byte in an equivalent do...while

Can you post this "equivalent" do...while?

There is no equivalent anyway. One tests at the start of the loop, the other at the end. Thus they will always behave differently.

byte k = 255;
do {
//do stuff
k--;
} 
while (k >= 0);

Something like that?

The comparison is always true, no matter where you put it. The fact that you made k unsigned has no bearing on the loop behaviour. It will always be positive.

Agreed. I don't see how k in this case can ever be negative.

byte k = 255;
do {
  ...
} while (k-- > 0);

The issue is trying to use a for-loop or while-loop to iterate 2^N times with a variable of N bits - it cannot be done as for loops test before the body and all possible values of the variable are valid before body.