if ( condition1 && condition2 && condition3 && condition4 )
{
//do something
}
For AND, conditions are started checking from the first one on left, i.e. condition1. If condition1 is false, the rest of the conditions are not checked and it comes out of the if block.
If condition1 is true, then it proceeds checking the next condition to the right, i.e. condition2. At any point if it encounters a false, it skips the if block.
if ( condition1 || condition2 || condition3 || condition4 )
{
//do something
}
For OR, conditions are started checking from the first one on left, i.e. condition1. If condition1 is true, the rest of the conditions are not checked and it enters the if block.
If condition1 is false, then it proceeds checking the next condition to the right, i.e. condition2. At any point if it encounters a true, it enters the if block.
No comments:
Post a Comment