While loop with variable ++

advertisements

Sorry for this easy question but I couldn't find the answer, if I got a while loop that looks like this. Does it calculate before or after the comparison?

a = 0;
while(a++ < 5)
{
    ....

When it first runs the loop will it look at it as "1 < 5" or "0 < 5". Thanks


Comparison is done BEFORE the increment, but the body of the loop sees the value AFTER icrementation. So in the first run you'll compare 0 < 5, but in the loop a will have the value of 1.