Programming languages - AQARelational operations

Proficient programming requires knowledge of many techniques. These techniques allow for powerful, complex programs to be created.

Part ofComputer ScienceComputational thinking and problem solving

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 “Good Password!”
ELSE OUTPUT “Password too short”
ENDIF