Logical Operator

Logical operator are used to check multiple conditions in a given conditional statement rather than using nested if-else statement. To check multiple conditions in a conditional statement you must either use “&&”(And) or “||”(or) in between a pair of conditions.

For “&&” every statement must be true so that the whole statement will be true and the block of code will be executed. For “||” at least one condition must be true for the statement to be true and the block of code will be executed.

logicalStatement
Example of logical operator. In this case both if statement will be executed with comments.

Leave a comment