Operators in C
C language supports a rich set of built-in operators. An operator is a symbol that tells the compiler to perform a certain mathematical or logical manipulation. Operators are used in programs to manipulate data and variables.
* These C operators join individual constants and variables to form expressions.
* Operators, functions, constants, and variables are combined together to form expressions.
* Consider the expression A + B * 5. where, +, * are operators, A, B are variables, 5 is constant and A + B * 5 is an expression.
C operators can be classified into the following types:
- Arithmetic Operators
- Assignment Operator
- Logical operators
- Relational operators
- Increment and Decrement Operator
- Conditional Operator/ ternary operator / ?: Operator
- sizeof()
- comma operator
- typedef statement
- Constant variable
- Enumeration (enum)
- Type conversion/Type casting
Types of Operators | Description |
Arithmetic operators | These are used to perform mathematical calculations like addition, subtraction, multiplication, division and modulus |
Assignment operators | These are used to assign the values for the variables in C programs. |
Relational operators | These operators are used to compare the value of two variables. |
Logical operators | These operators are used to perform logical operations on the given two variables. |
Bit wise operators | These operators are used to perform bit operations on given two variables. |
Conditional (ternary) operators | Conditional operators return one value if the condition is true and returns another value is the condition is false. |
Increment/decrement operators | These operators are used to either increase or decrease the value of the variable by one. |
Special operators
Types of Operators | Description |
sizeof() | This helps us to find the size of a data type or a variable |
comma operator | Used while declaring variable and technical questions |
typedef statement | Gives a user-defined name to an existing data type |
Constant variable | to declare constant and use them |
Enumeration (enum) | |
Type conversion / Typecasting |