In every programming language, we need to do several operations like mathematical, comparison, condition checks, etc.
So to let the machine understand the actions we want to do there are some operators that are predefined.
We can use those operators between two operands and can do the required operations easily.
Let's start here.
Operators
- Arithmetic Operator
- Relational Operator
- Logical Operator
- Bitwise Operator
- Assignment Operator
- Ternary Operator
Operators |
|
1. Arithmetic Operator
|
+,-,*,%,++,--
|
2. Relational Operator
|
==,!=,>,<,>=,<=
|
3. Logical Operator
|
&&,||,!
|
4. Bitwise Operator
|
&,|,~,^,<<,>>
|
5. Assignment Operator
|
=,+=,-=,*=,/=,%=,<<=,>>=,&=,|=,^=
|
i. Ternary Operator
|
?:
|
Let's know more about these operators
Arithmetic Operator
Operator |
Description |
+
|
Adds two Operands
|
- |
Used for subtraction
|
*
|
Used for multiplication
|
/
|
Used for Division
|
%
|
Used for Modulus
|
++
|
Increment Operator
|
--
|
Decrement Operator
|
Relational/Comparision Operator
Operator |
Description |
==
|
Compares both side values returns true if both are equal
|
!=
|
Compares both side values returns true if both are not equal
|
>
|
Checks if the left side value is greater than the right side value
|
<
|
Checks if the left side value is less than the right side value
|
>=
|
Checks if the left side value is greater than or equal to the right side value
|
<=
|
Checks if the left side value is less than or equal to the right side value
|
Logical Operator
Operator |
Description |
&&
|
AND Operator returns true if both sides are non zero
|
||
|
OR Operator returns true if any of the sides is non zero
|
!
|
NOT Operator returns the reverse value of the result;
if the result is true then it will return false and vice versa
|
Bitwise Operator
Operator |
Description |
&
|
Bitwise AND Operator
|
|
|
Bitwise OR Operator
|
~
|
Bitwise NOT Operator
|
^
|
Bitwise XOR Operator
|
<<
|
Bitwise Left Shift Operator
|
>>
|
Bitwise Right Shift Operator
|
Assignment Operator
Operator |
Description |
=
|
Equals to, Assigns right side result to left side Operand
|
+=
|
Add and Assignment Operator
|
-=
|
Subtract and Assignment Operator
|
*=
|
Multiply and Assignment Operator
|
/=
|
Divide and Assignment Operator
|
%=
|
Modulus and Assignment Operator
|
<<=
|
Left shift and Assignment Operator
|
>>=
|
Rightshift and Assignment Operator
|
&=
|
Bitwise AND and Assignment Operator
|
|=
|
Bitwise OR and Assignment Operator
|
^=
|
Bitwise XOR and Assignment Operator
|
Ternary Operator
Operator |
Description |
?:
|
Syntax:- ConditionalStatement?The true expression: The false Expression
checks the condition and returns the true expression else returns the false expression
|
Thank You