Operators In C++

Card image cap

Definition of 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.


Card image cap

Arithmetic Operators

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

Card image cap

Increment and Decrement Operators

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

Card image cap

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

Card image cap

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.

Card image cap

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
Card image cap

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

Card image cap

Example :



Output :

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

Card image cap