In this tutorial, we will learn what an operator is and its types-unary and binary, and the types of unary and binary operators, and the difference between the unary operator and binary operator. So let us start.
An operator is a symbol or sign that operates on a value or a variable. In any of the programming languages, there are different-different types of mathematical & logical calculations. To perform the mathematical and logical operations some special symbols are used. For performing Different-different types of calculations the computer needs some symbols which are called an operator. For defining the data identifiers are used.
There are two types of operators. The unary operator and the binary operator.
The operators which need only one operand for performing the operation are known as Unary operator. In the C language, the unary operators that are supported are of different - different types. For Example: -
|&||Address operator||*||Indirection operator|
|+||Unary +||-||Unary -|
|~||bitwise operator||++||Unary increment operator|
|:||Logical operator||--||Unary decrement operator|
Those operators who need two operands for performing the operations are known as binary operators. For example:
An arithmetic operation will perform mathematical operations like addition, subtraction, multiplication, division, etc.
This operator checks the relationship between the two operands. If the relation is true then it returns the value 1 and if the relation is false then it returns the value 0.
In the logical operator, the value 1 or 0 is returned depending upon whether the expression result is true or false.
The ternary operator uses three operands instead of one or two. The condition operator checks the condition and assigns the value according to the condition.
These operators are used for incrementing or decrementing the value in a variable by 1.
During the mathematical operations like addition, subtraction, etc. are converted into a bit-level for making the processing faster.
This operator is used to assign a value to the variable. The most common assignment operator is =
It is used to link related expressions together.
By using this operator we can get the size of the data
|Unary operator||Binary operator|
|Performs the action with a single operand||Performs the action with two operands|
|These contain the arithmetic operators||These contain arithmetic, logical, conditional, relational operators|