This question applies I suppose to programming in general, but my application is built in MATLAB (based on C++):
In a while loop, if the while condition is no longer satisfied, does the loop run to its completion or does it exit at the exact moment that the conditions of the while loop are no longer satisfied?
e.g.
x = 1
while (x = 1)
{
x = 0
(some code)
}
In this case, does (some code) run?
PS. I know the syntax is terrible, it’s just to illustrate the situation
It runs to completion. The while is only considered at entry to the loop block. So yes, (some code) does run.