Relational and Logical Expressions

Relational and Logical Expressions

    Relational expressions
    BASIC allows the construction and use of relational expressions and are formed by using the relational operators. These operators are
    Relational expressions are constructed by combining two arithmetic expressions with relational operators.
    The general form is
    Mean
    Where dr indicates a relational operator.
    Eg; A=2, B=3
    A = B , A > B A < B
    False False True
    Relational expression are commonly used to test conditions in IF–THEN ELSE statements.
    Logical Expressions
    Logical expressions are designed using logical operators and relational expressions. commonly used logical operators are NOT, AND, OR, XOR, EQV. The following tables explain their action. Such tables are called truth tables.
    NOT Table

    Not
    AND Table


    A_and_B.jpg
    XOR table
    Xor.jpg
    EQV table
    Eqv
    Example
    eg
    Logical expressions may be used in the IF –THEN & IF –THEN –ELSE statements as test conditions like relational expressions.
    The order of evaluation of the operators is as follows
    Table


Last modified: Wednesday, 18 January 2012, 11:24 PM