Let us see a list of Operators in C++.
- Relational Operators
- Logical Operators
- Arithmetic Operators
- Bitwise Operators
- Assignment Operators
- Misc Operators
Relational Operators
Some of the relational operators supported by C++ language are mentioned below;
Operator | Condition | example | result |
== | If(n1==n2) | If(5==5) | True |
If(n1==n2) | If(5==6) | False | |
!= | If(n1 != n2) | If(5==6) | True |
If(n1 != n2) | If(5==5) | False | |
> | If(n1 > n2) | If(6 > 5) | True |
If(n1 > n2) | If(5 > 6) | False | |
< | If(n1 < n2) | If(5 < 6) | True |
If(n1 < n2) | If(6 < 5) | False | |
>= | If(n1 >= n2) | If(5 >= 5) | True |
If(n1 >= n2) | If(2 >= 5 | False | |
<= | If(n1 <= n2) | If(4 <= 5) | True |
If(n1 <= n2) | If(5 <= 4 | False |
Logical Operators
Some of the relational operators supported by C++ language are mentioned below;
Operator | Condition | example | result |
&& | If(n1==n2 && n1==n3 ) | n1=6
n2=4 n3=1 |
True |
If(n1==n2 && n1==n3 )
|
n1=1
n2=4 n3=6 |
False | |
|| | If(n1==n2 || n1==n3 ) | n1=6
n2=4 n3=7 |
True |
If(n1==n2 || n1==n3 )
|
n1=6
n2=4 n3=2 |
False |
Arithmetic Operator
- +
- –
- *
- /
- %
- ++
- —
Bitwise Operators
Some of the bitwaise operators supported by C++ language are mentioned below;
p | q | p | q | p ^ q |
0 | 0 | 0 | 0 |
0 | 1 | 1 | 0 |
1 | 1 | 1 | 1 |
1 | 0 | 1 | 0 |