C++ Operators


Operators are symbols which can function as logical and mathematical operation in C++ program.

An operator is a symbol that represents and tells the compiler to perform some specific mathematical or logical manipulations. The value that the operator operates is known as operands.

C++ operators

Below are Operators which are used in the C++ program:

  • Arithmetic operators
  • Assignment operators
  • Relational operators
  • Logical operators
  • Bit wise operators
  • Conditional operators (ternary operators)
  • Increment/decrement operators
  • Special operators

Operators Description Examples
Arithmetic operators (+,-,*,%,/) Addition of two number A=10, B=20, C=A+B, C=30
Assignment operators (=, ^=, -=, *=, /=, %=, &=, +=) Assigns values from right side operands to left side operand x=10, y=20, the value of x+y assign to z
Relational operators (>, <, >=, <=, ==, != ) Check the two values are equal or not. If yes, then the condition becomes true. (A == B) and (10==10) is true.
Logical operators (&& , ||, !) If (A && B) are non-zero, then the condition becomes true. int a=10, b=2; if(a==10&&b==2) is true
Bitwise operators (&, |, ~, ^, <<, >>) [& – Bitwise AND, | – Bitwise OR, ~ – Bitwise NOT, ^ – XOR, << – Left Shift, >> – Right Shift] int a=10, b=14; if(a& b) is true
Conditional operators (ternary operators)(?:) (Condition? true_value: false_value); (A > 100 ? 0 : 1);
Increment/decrement operators(++, --) Pre/Post-increment, Pre/Post-decrement int i=10; i++;
Special operators [&, *, Sizeof ()] & (address of the variable), *(pointer to a variable), Sizeof () (size of the variable) int a=10; sizeof (a) integer, will return 4.



OnlineTpoint is a website that is meant to offer basic knowledge, practice and learning materials. Though all the examples have been tested and verified, we cannot ensure the correctness or completeness of all the information on our website. All contents published on this website are subject to copyright and are owned by OnlineTpoint. By using this website, you agree that you have read and understood our Terms of Use, Cookie Policy and Privacy Policy.