In C language operators are pre define. It is represented by symbols. An expression is created by using one or more operand with operator.
In C language there are four basic type of operator.
- Unary Operator
- Binary Operator
- Conditional Operator
- Bit wise Operator
1. Unary Operator : Unary operator are those operator in which one operator is used to create one expression.
There are three type of unary operator:
There are three type of unary operator:
- Increment Operator
- Decrement Operator
- Size of Operator
a. Increment Operator :This operator is used to increment operand by 1. Such as : ++i or i++ or i=i+1
b. Decrement Operator :This operator is used to decrement operand by 1. Such as : --i or i-- or i=i-1
c. Size of Operator :This operator is used to specify the size of memory sued by operand. Such as : sizeof(i);
2. Binary Operator :Binary operator are those operator in which two operator are used to create one expression.
There are four type of binary operators:
There are four type of binary operators:
- Mathematical Operator
- Relational Operator
- Logical Operator
- Assignment Operator
a. Mathematical Operator :This operator is used to do all type of arithmetic calculations. Such as:
- Addition (+)
- Subtraction (-)
- Multiplication (*)
- Division (/)
- Modulus (%) it return remainder After integer division.
b. Relational Operator :It is used to check the relation between two variables. Such as:
- Less then (<)
- Greater then (>)
- Less then or equal (<=)
- Greater then or equal (>=)
- Equal to (==)
- Not Equal to (!=)
c. Logical Operator :It is used to perform logical operations. It is generally used in if condition such as:
- AND (&&) It must contain two conditions
- OR (||) It must contain two conditions
- NOT (!)
d. Assignment Operator :It is used to assign any value or any expression such as : a=b+c; , a=6;
3. Conditional Operator (?:) : Conditional operator is used for decision making. It is also known as single line if-else statement.
4. Bit-wise operator :It is used to perform bit-wise operation. Binary bits are used to perform operation. That involve the manipulation of individual binary bit. It is three type :
- Bit-wise or conferment operator (~)
- Bit-wise logical operator (&)(^)
- Bit-wise shift operator (<< and >>)
Hierarchy (Precedence) of operators
Precedence of operators are as follow:
Precedence of operators are as follow:
No comments:
Post a Comment