On 08/12/2010 11:00 AM, mahmoodn wrote: > > Dear all, > > First consider this: > bool flag = false; > while (condition) { > ... > if ( !flag && ANOTHER_CONDITION ) { > .... > } > } > If the "while" loop iterates for 10 times, the both flag and > ANOTHER_CONDITION are checked 10 times. > > Now consider this: > bool flag = false; > while (condition) { > ... > if ( !flag && ANOTHER_CONDITION ) { > .... > flag = true; > } > } > If the "while" loop iterates for 10 times and in the first iteration "flag = > true;" is executed, then how many times, ANOTHER_CONDITION is checked? 1 or > 10? Once. It's part of the definition of && that its right-hand-side doesn't get used if its left-hand-size evaluates to false. Andrew.