+ 4
How you will define order if condition is like this if(a && b) { } elae if (a || b) { } else if (!false) { } Or if(a || b) { } elae if (a && b) { } else if (!false) { } Different condition different order There is no fixed order but boolean operators always execute from left to right. so if && comes first then &&, will execute if || comes first then || will execute.
8th Jul 2023, 4:09 PM
A͢J
A͢J - avatar
+ 2
Sooraj Kumar As I said left to right so if X is true then True will be return as per your given example and rest will not execute means Y && !Z are nothing if X is true decision always happens from left
8th Jul 2023, 11:35 PM
A͢J
A͢J - avatar
8th Jul 2023, 2:12 PM
Sakshi [Offline 🙃]
Sakshi [Offline 🙃] - avatar
+ 1
This is decided by "operator precedence" rules. It could be slightly different in every language. Here is the documentation for C: https://en.cppreference.com/w/c/language/operator_precedence ! (not) comes first && comes next || comes last (do not confuse || vertical bars with lowercase L characters!) In your example: X=true, Y=false and Z=true X || Y && !Z = X || (Y && (!Z)) = true
8th Jul 2023, 5:14 PM
Tibor Santa
Tibor Santa - avatar