Wouldn't C cause an infinite loop?


i = 1
(i *= 2) == (i * i) (at least in most interpreted languages ive seen)
1 * 1 == 1
so i would infinitely be 1 unless im missing something?


No it wouldn’t cause an infinite loop because i is being incremented by *2 so if i started at 2 the next increment is 4 until i < n isn’t true


It wouldn’t be an infinite loop. i*=2 means that you multiply the value of i by 2 and save it inside i. Meaning that, if i is 1 for the next loop it’ll be 2, and the next one would be 4, and so on.