You are here

Precedence of Operators Chart

5 February, 2015 - 11:20

Each computer language has some rules that define precedence and associativity. They often follow rules we may have already learned. Multiplication and division come before addition and subtraction is a rule we learned in grade school. This rule still works. The precedence rules vary from one programming language to another. You should refer to the reference sheet that summarizes the rules for the language that you are using. It is often called a Precedence of Operators Chart. You should review this chart as needed when evaluating expressions.

A valid expression consists of operand(s) and operator(s) that are put together properly. Why the (s)? Some operators are:

  1. Unary that is only have one operand
  2. Binary that is have two operands, one on each side of the operator
  3. Trinary which has two operator symbols that separate three operands

Most operators are binary, that is they require two operands. Within C++ there is only one trinary operator, the conditional. All of the unary operators are on the left side of the operand, except postfx increment and postfx decrement. Some precedence charts indicate of which operators are unary and trinary and thus all others are binary.