To compare more then one condition or we have to use multi conditional structure is called Compound Comparison. Its used to execute set of statements by testing many conditions.
As we learnt about extended if then else structure in our previous lesson here is almost same thing but we can say it’s little bit more advanced and also complicated.
Or we can say here is something to decision making in our program logic. We can face many conditions at same time and have to handle them using few logical operators.
While using if statements we can handle comparisons but using compound comparison it would be more easy to program even it will shorten our source code along with more functionality.
We will better understand it when we will use it in our realy projects. Dont worry in next lessons we will create a complete project to be expert in programming world. for now we will discuss main Three logical operators which we use in compound comparison.
We use logical operators for multi conditional structure. There are main three logical operators we will discuss in this tutorial.
AND operator is used to check or compare two conditions. It returns TRUE if both conditions are true and returns FALSE if any one is False condition from both.
The OR operator is also used to compare two conditions. It returns TRUE if one of both conditions is true. And returns FALSE if both conditions are false.
Its very useful and mostly used in programming. NOT operator is used to reverse the output of any comparison. It will return true if the result of condition is false and if the result is true it returns false.