Operators in C
Operators and Operands –
The operations being carried out on data, are represented by operators. and the data/object on which operation is to be applied is referred as operands.
Consider an expression [(m+n)(e-7)] , where m,n,e are operands or data or objects and +,-, are operators in C++.
Operators in C joins variables and constants to form expressions.
C++ is very rich in built-in operators. Different classes of operators in C++ are –
- Arithmetic_operators –
These are further divided into two classes again which are –
- Unary operators (+ -) and
- Binary operators. (+ – / * %)
- Increment/decrement operators
These are divided into –
- Post Increment
- Pre Increment
- Relational operators
- Logical operators
- Bit wise operators
- Conditional (ternary) operators
- Other operators
- Assignment_operators (or) c++ shorthands
| S.no | Types of Operators | Description | |
| 1 | Arithmetic operators | Performs maths calculations like addition(+), subtraction(-), division(/), multiplication(*) and modulus(%) | |
| 2 | Increment/decrement operators | Used to either increase or decrease the operand value of the variable by one. | |
| 3 | Relational operators | Performs comparison of value of two variables. These operators establish relationships among the values. | |
| 4 | Logical operators | Performs logical operations on the given two variables. It tells how the relationships among values can be connected. | |
| 5 | Bitwise operators | Performs bit operations on given two variables. | |
| 6 | Conditional (ternary) operators | Ternary operator returns one value if condition is true and returns another value if condition is false. | |
| 7 | Other operators | &, *, sizeof( ), comma (,). | |
| 8 | Assignment operators or c++ shorthands | used to assign the values for the variables in C++ programs. | |