3.1 Introduction to Operators and Expression
Operators and Expressions
Introduction
C supports a rich set if build in operators. An operator is a symbol that tells the computer to perform mathematical or logical manipulations. Operators are used in programs to manipulate data and variables. They usually form a part of mathematical or logical expressions. C operators can be classified into a number of categories.
For example in the expression: c = a+b
Operators are = and +
Operand are a,b and c
On the basis of number of operand :
- Unary Operator : This operator requires only one operand.
Eg: ++(increment), --(decrement)
Expression: ++a, --b
- Binary operators: This operator requires two operands.
Eg: +,-,*,/
Expression: a+b, a/b
- Ternary operator: This operator requires three operands.
Eg: (? :) conditional operator
Expression: (a>b)? a:b
On the basis of function
- Arithmetic operators
- Relational operators
- Logical operators
- Assignment operators
- Increment and Decrement operators
- Conditional operator
- Bitwise Operator
- Special Operator