+ 1
Can anyone explain how does while(condition, condition) work
What does the ',' stand for is it a logical operation(&& , || )?
3 ответов
+ 2
the comma operator will always yield the last value in the comma separated list.
basically it's a binary operator that evaluates the left hand value but discards it, then evaluates the right hand value and returns it.
if you chain multiple of these they will eventually yield the last value in the chain, this is useful if you want to evaluate the left hand value before the right hand value (if the left hand evaluation has a desirable side effect).
for example i < (x++, x/2) would be a sane way to use that operator because you're affecting the right hand value with the repercussions of the left hand value evaluation.
+ 2
thank you for the through explanation
one more question correct me if im wrong
in this code piece in c
While(a>7 , b>17){
a++
b++
}
Since <b> is not dependent on <a> first condition is completely ignored and only the second one matter?
+ 2
yes , the extreme right expression decides the termination condition of the loop.