Flowgorithm Logical Operators
The Flowgorithm Logical operators are as follows:
Logical Operator | Operator Symbol | Description |
Logical AND | &&, AND, ∧ | The Logical AND operator is a binary operator. It requires two boolean conditional expressions to be evaluated as True or False. The Logical AND returns True if both the conditions are True. Otherwise, it will return False. |
Logical OR | ||, OR, ∨ | The Logical OR operator is also a binary operator. It requires two boolean conditional expressions to be evaluated as True or False. The Logical OR returns False if both the conditions are False. Otherwise, it will return True. |
Logical NOT | !, NOT, ¬ | The Logical NOT operator is a unary operator that requires only one boolean conditional expression. It negates the given condition. If the condition is False, it will return True; if it is True, it will return False. |
Common Errors
While working with logical operators, you may encounter common errors such as:
Syntax Error
AND and OR conditional operators are binary operators. The operators require two boolean conditional expressions to evaluate the compound truth value. We get syntax errors if we omit or don’t supply two conditional expressions.
The AND operator requires two conditional expressions. In this example, the programmer supplied only one expression, which resulted in an error.
Type Mismatch Error
The conditional operators operate on Boolean data types. The conditional expressions should have Boolean results i.e. either True or False. In this example, the programmer is trying to use String datatypes along with conditional operators. This would result in a Type Mismatch error. The fix is to remove the quotes in the expressions.
For example, “age > 18” enclosed within double quotes is a String data type in Flowgorithm, not a conditional expression.
Logical operators are used in control structures like if-statements and loops to make decisions based on multiple criteria in Flowgorithm flowcharts.