C++ Tutorial – Operators in C++ Language

Operators are symbols used to perform operations. There can be various types of operations, such as arithmetic, logical, bitwise, etc.

In C++, there are the following types of operators that perform different kinds of operations.

  • Arithmetic Operators

  • Relational Operators

  • Logical Operators

  • Bitwise Operators

  • Assignment Operators

  • Unary Operators

  • Conditional or Ternary Operators

  • Miscellaneous Operators

C++ Tutorial - Operators in C++ Language

👇 Click to receive 👇
👉 C Language Knowledge Resource Collection

Cpp Operators 1 – Operator Precedence in C++

The precedence of operators indicates which operator is executed first, followed by the next operator. Associativity specifies the direction of evaluation for operators, which can be left to right or right to left.

Let’s understand precedence through the following example:

 int data=5+10*10;

The “data” variable will contain 105 because the * (multiplication operator) is evaluated before the + (addition operator).

Here are the precedence and associativity of C++ operators:

Category Operator Associativity
Postfix () [] -> . ++ — Left to Right
Unary + – ! ~ ++ — (type)* & sizeof Right to Left
Multiplicative * / % Left to Right
Additive + – Right to Left
Shift << >> Left to Right
Relational < <= > >= Left to Right
Equality == != Right to Left
Bitwise AND & Left to Right
Bitwise XOR ^ Left to Right
Bitwise OR | Right to Left
Logical AND && Left to Right
Logical OR || Left to Right
Conditional ?: Right to Left
Assignment = += -= *= /= %= >>= <<= &= ^= |= Right to Left
Comma , Left to Right

C++ Tutorial - Operators in C++ Language


 Popular Recommendations
  • C Language Tutorial – Detailed Explanation of Armstrong Numbers in C

  • C Language Algorithm – “String Multiplication” Algorithm Problem

  • C++ Tutorial – Data Types in C++ Language

Leave a Comment