top of page

Relational and Logical Operators

Relational and Logical operators are used to compare and combine.

Logical Operators:

rationalandlogical2.png

Rational Operators:

rationalandlogical1.png

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:

rationalandlogical4.png

Example:

rationalandlogical3.png

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:

rationalandlogical6.png

Example:

rationalandlogical5.png

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.

  • Twitter
  • LinkedIn
  • discord-logo--v2
  • kisspng-github-pages-logo-repository-fork-github-logo-1-magentys-5b69de71b51265

Dragon Eye Intelligence LLC

bottom of page