How the more than one conditions are evaluated in a while loop?

lets have a while loop below …

while(condition1 && condition2 && condition3){
// do something
Actually I wannna to ask that either the conditions are evaluated in an specific order (i.e left->right or right->left) ?

Hey @hammad321
I think the loop will only run if all the conditions are met since you are using the logical operator AND so it will only run if condition 1 is true and condition 2 is true and condition 3 is true if one is false the loop terminates.
If you want a loop that will execute at least once even if the condition is false use the do…while loop hope this helps


hmmm, you are absolutely correct it means it will evaluate from left to right if it encounters a false condition in the first, then there is no need to check the remaining conditions in that case and the loop will be terminated. :grinning: