Knowing which way to iterate the for loop C
You have a really complicated example with variables, and a simpler one with literals. The literal one is only going to use one branch. So let's do a simple one with variables. Let's say you want to iterate from a to b, but you don't know which is larger. Well, first of all, unless I'm missing something, if a>b, then you'll want integer -= increment in the second branch, while your code has integer += increment in both. So before your for-loop, define a variable direction equal to the sign of b-a (that is, if b-a &gt;0 then direction = 1, if b-a&lt;0 then direction = -1). Then do:

for(integer = a; (b-integer)*direction &gt; 0; integer += direction*increment)