Operators

Cards (22)

  • Operators are special characters that perform certain functions
  • Arithmetic operators take two values and perform a maths function on them
  • The exponentiation operator is used to raise a number to a power
  • The DIV operator returns the whole number part of a division , and the MOD operator gives the remainder
  • Dividing integers might behave oddly in some programming languages (e.g. 5 / 2 may give 2 instead of 2.5), so using DIV and MOD can avoid these issues
  • The typical operator for the Addition function is +
  • The typical operator for the Subtraction function is -
  • The typical operator for the Multiplication function is *
  • The typical operator for the Division function is /
  • The typical operator for the Exponentiation function is ^ (or **)
  • The typical operator for the Quotient function is DIV
  • The typical operator for the Remainder(modulus) function is MOD (or %)
  • When using operators, computers follow the rule of BODMAS - To make sure your code is doing what you want it to , you should use brackets
  • The assignment operator , = , is used to assign values to constants or variables
  • Comparison operators compare the expression on their left hand side to the expression on their right hand side , and produce a Boolean value (true or false)
  • The comparison operator == means?
    Is equal to
  • The comparison operator != or <> means?
    Is not equal to
  • The comparison operator < means?
    Is less than
  • The comparison operator > means?
    Is greater than
  • The comparison operator <= means?
    Is less than or equal to
  • The comparison operator >= means?
    Is greater than or equal to
  • A common mistake is to get the assignment operator " = " and the comparison operator " == " mixed up - You'll know you've used them incorrectly because your code won't behave as intended