Operators in C
An operator is a symbol that specifies the operation or activity to be performed. For example + means add , - means subtract and * means multiply.
a + b /*Here a and b are operands and + is an operator */
a++ /*Here a is operand and ++ is the operator */
We can classify operator on
- Number of operands an operator has.
- The type of operation being performed.
1. Operators classification based on number of operands
Based on number of operand, operators can be classified into four major category.
Unary Operators: An operator which act on only one operand to produce result is called unary operator. For example +x, ++a, !b
Binary Operators: An operator which act on two operands to produce result is called binary operator. For example a+b, a%b, a>>1
Ternary Operators: An operator which act on three operands to produce result is called ternary operator. For example x?y:x.
2. Operators classification based on type of operation
Classifying based on type of operation being performed gives a clear picture of all operators.
we will discuss each operator in detail with example in next topics.