Search

# C++ Operators

What is Operator ?

used to perform operations on data

An operator is simply a symbol that is used to perform operations. There are many types of operations like arithmetic, logical, bitwise etc & there are many operators in C++ language

There are following types of operators to perform different types of operations in C++ language.

Here Binary means minimum two operands is required to use an operator

Ø Arithmetic Operators [Binary] +, -, /, *

Ø Relational Operators [Binary] <, >, <=, >=

Ø Logical Operators [Binary] &&, ||

Ø Bitwise Operators [Binary] &, |, <<, >>

Ø Assignment Operator [Binary] =, +=, -=

Ø Unary operator ++, --

Ø Ternary or Conditional Operator ?:

Ø Misc Operator

Precedence of Operations in C++

The precedence of operator specifies that which operator will be evaluated first and next. The associativity specifies the operators direction to be evaluated, it may be left to right or right to left.

Let’s understand the precedence of operations in C++

int test=10+10*10;

The "test" variable will contain 110 because * (multiplicative operator) is evaluated before + (additive operator).

The precedence and associativity of C++ operators is shown below in a table:

Category

Operator

Associativity

Postfix

() [] -> . ++ - -

Left to Right

Unary

+ - ! ~ ++ - - (type)* & sizeof

Right to Left

Multiplicative

* / %

Left to Right

Addictive

+ -

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

Move to Next Page

---------------------------------------------------------------------------------------------------------------------------

Previous Page Next Page

Download C++ Projects

Join us on LinkedIn – Great Place of Networking

Follow us on More Together – Facebook for regular updates

Mandatory to join Telegram group for regular job updates

Mandatory to join whatsapp group for regular job updates

Other C++ Topics

For Other Tutorials

Tags:

47 views0 comments

### Related Posts

See All

#### Number to Character Conversion in C++

Program to implement Number to Character Conversion in C++ Firstly see what we are going to do ? Like this 0 - zero 1 – one 2 – two 3 – three 4 – four 5 – five 6 – six 7 – seven 8 – eight 9 – nine How

#### Factorial of a number in C++

In this tutorial we are going to see how to find a factorial of number using C++ program Firstly let’s see a example to understand it better n! = n + (n-1) + (n-2) ! n>=1 3! = 3 *2*1 = 6 Program to fi

#### Fibonacci Triangle in C++

Program to implement Fibonacci Triangle in C++ #include <iostream> using namespace std; int main() { int a=0,b=1,i,c,n,j; cout<<"Enter the limit: "; cin>>n; for(i=1; i<=n; i++) { a=0; b=1; cout<<b<<"\