Operators in C

Operators are used to perform mathematical and logical calculation in program.




Operator vs Operand

Pictorial Explanation

operator vs operand

Classifications of Operators




Unary operator

Only one operand is required to perform calculation.


++(increment operator)

-- (decrement operator)

Example

a = 5;

++a;

--a;





Binary Operator

Two operands are required to perform calculation.


+, -, *, % etc.

Example

a = 5;

b = 15;

a + b;

a - b;





Ternary Operator

Three operands are required to perform calculation.


Example

(expression 1)? (expression 2): (expression 3);

a > b?printf("a"):printf("b");


It is also called as a conditional operator in c.