top of page


Relational and Logical Operators
Relational and Logical operators are used to compare and combine.
Logical Operators:

Relational Operators are used to compare values whether they be static or variables does not matter as long as they are of the same type. We will create a while loop that runs until the condition of a variable being less than a number is no longer met, in which case the loop will end.
Output:

Example:

Since the relational operation x<5 is used as the condition in the while loop, the loop will break once x is equal to 5.
Logical operators can be used to conjunct operations. In this example we want to make sure x is less than 5 and y is greater than 12.
Output:

Example:

The and && operator is used to ensure multiple conditions are met. If we wanted to make sure just at least one condition was met we would use the or || operator.
bottom of page
