The operators may be classified as:
Unary Operator:
The operator that works on a single operand is known as a unary operator.Binary Operator:
The Operator that works on 2 operands is known as a binary operator.Various operators used in C are given below:
1. Arithmetic Operators:
Arithmetical Operator of C are given below:
+ |
It is an addition operator. It is used to add the 2 operands given with this operator. For example: 2 + 4 gives 6 |
- |
It is known as the subtraction operator which is used to subtract the operand given after the subtraction operator from the operand given before the operator. For example, 10 – 5 gives 5 |
* |
It is known as the multiplication operator that is used to give the product of the operands given with the operator. For example, 2 * 3 gives 6 |
/ |
It is known as the division operator that is used to divide the operand given before the operator by the operand given after the operator. For example, 20 / 2 gives 10 |
% |
It is known as the modulus operator that is used to find out the remainder when the first operator is divided by the second operator. For example, 55 % 10 gives 5 10 ) 65 (6 60 ---- 5 ---- |
++ |
It is a unary operator known as increment operator. It is used to increment the value of the given operand by 1. For example, 5++ will be 6 |
-- |
It is a unary operator known as the decrement operator. It is used to decrement the value of given operand by 1. For example 10– will give 9 |
Increment Operators are of two types :
Pre-Increment Operator:
Post-Increment operator:
Decrement operators are also of two types:
Pre-Decrement operator:
Post-Decrement Operator:
2. Relational Operators:
== |
It is the operator used to check whether the given two entities are equal or not. For example, 10 == 20 evaluated to 0 and, 50 ==50 evaluated to 1 |
!= |
It is the operator used to check if the given 2 entities are not equal. For example, 20 != 20 evaluated to 0 but, 20 != 30 evaluated to 1 |
< |
It is the operator used to check if the first entity is less than the second entity or not. For example, 20 < 30 evaluated to 1 but, 30 < 20 evaluated to 0 |
> |
It is the operator used to check whether the first entity is greater than the second entity. For example, 20 > 30 evaluated to 0 and 30 >20 evaluated to 1 |
<= |
It is the operator used to check whether the first entity is either less than or equal to the second entity or not. For example, 30 <= 20 evaluated to 0 |
>= |
It is the operator used to check whether the first entity is either greater than or equal to the second operator. |
0 Comments