What is the order of precedence for C++ operators?

The priority order of C++ operators is as follows:

  1. Unary operators (such as increment, decrement, negation, etc.)
  2. Multiplication, division, and modulus operators.
  3. Addition and subtraction operators.
  4. Bitwise operators, such as bit left shift and bit right shift.
  5. Relational operators (such as greater than, less than, equal to, etc.)
  6. Bitwise operators such as bitwise AND, bitwise OR.
  7. Logical operators (such as logical AND, logical OR)
  8. Ternary operator (Conditional operator)
  9. Assignment operator
  10. comma operator

It is important to note that parentheses can be used in an expression to change the order of operations. The expression within the parentheses will be calculated first.

bannerAds