Operators In C++

Definition of C++ Operator ?

An Operator, in C+, are basically an operators wich is used to perform arithmetic operations that include multiplication, division, addition and subtraction and it also enable some special kind of operators to perform Operation of two or more digits of number etc.

All arithmetic operators compute the result of specific arithmetic operation and returns its result. The arguments are not modified.

Arithmetic operators "+" and "-" are used to manipulate pointers by adding or subtracting the numeric value to or from the pointers without generating any exception during overflow of the of the pointer's domain.

Arithmetic operators can be overloaded when used with user-defined types to extend the nature of normal operators, thus providing additional functionalities.

Arithmetic Operators

Operator Description Example
+ Addition a+b
- Subtraction a-b
* Multiplication a*b
/ Division a/b
% Modulus a%b

Increment and Decrement Operators

Operator Description Example
++ Post Increment a++
-- Post Decrement a--
++a Pre Increment ++a
--a Pre Decrement --b

Relational Operators

Operator Description Example
== Is equal to a==b
!= Is not equal to a!=b
> Greater than a>b
< Less than a<b
>= Greater than or equal to a>=b
<= Less than or equal to a<=b

Logical Operators

Operator Description
&& And operator. if both expressions evaluate to True, result is True. If either expression evaluates to False, result is False
|| Or operator. if either or both expressions evaluate to True, result is True
! Not operator. Performs logical negation on an expression.

Bitwise Operators

Operator Description
<< Binary left Shift Operator
>> Binary Right Shift Operator
~ Binary One's Complement Operator
& Binary AND Operator
^ Binary XOR Operator
| Binary OR Operator

Assignment Operators

Operator Description
= Assign
+= Increments, then assigns
-= Decrements, then assigns
*= Multiplies, then assigns
/= Divides, then assigns
%= Modulus, then assigns
<<= Left shift and assigns
>>= Right shift and assigns
&= Bitwise AND assigns
^= Bitwise exclusive OR and assigns
|= Bitwise inclusive OR and assigns

Example :

Output :

Simple Arithmetic Operators Example
a - b = 8
b * c = 24
a / c = 2
a + b * c = 36
a * b + c * d = 96code>