大象传媒

Relational operations

allow for and for comparisons to be made. They are used in testing such as and .

Relational operationOperatorExample
Assignment=x = 5
Equivalence= or ==if x = 5 or if x == 5
Less than<if x < 5
Less than or equal to<=if x <= 5
Greater than>if x > 5
Greater than or equal to>=if x >= 5
Does not equal<> or !=If x <> 5 or if x != 5
Relational operationAssignment
Operator=
Examplex = 5
Relational operationEquivalence
Operator= or ==
Exampleif x = 5 or if x == 5
Relational operationLess than
Operator<
Exampleif x < 5
Relational operationLess than or equal to
Operator<=
Exampleif x <= 5
Relational operationGreater than
Operator>
Exampleif x > 5
Relational operationGreater than or equal to
Operator>=
Exampleif x >= 5
Relational operationDoes not equal
Operator<> or !=
ExampleIf x <> 5 or if x != 5

The code below uses a condition to check if the password entered is the correct length of six or more characters:

password 鈫 USERINPUT
IF LEN(password) >= 6 THEN
     OUTPUT 鈥淕ood Password!鈥
ELSE
     OUTPUT 鈥淧assword too short鈥
ENDIF