An operator is a symbol that performs an operation on one or more operands.
Used for mathematical calculations.
| Operator | Operation |
|---|---|
+ | Addition |
- | Subtraction |
* | Multiplication |
/ | Division |
% | Modulus |
Example
Used to compare two values.
| Operator | Meaning |
|---|---|
== | Equal to |
!= | Not equal to |
> | Greater than |
< | Less than |
>= | Greater than or equal to |
<= | Less than or equal to |
Used to combine conditions.
| Operator | Meaning |
|---|---|
&& | Logical AND |
| ` | |
! | Logical NOT |
Used to assign values.
| Operator | Description |
|---|---|
= | Assign |
+= | Add and assign |
-= | Subtract and assign |
*= | Multiply and assign |
/= | Divide and assign |
Used to increase or decrease value by 1.
| Operator | Description |
|---|---|
++ | Increment |
-- | Decrement |
Example
Used for bit-level operations.
| Operator | Operation |
|---|---|
& | AND |
| ` | ` |
^ | XOR |
~ | NOT |
<< | Left shift |
>> | Right shift |
Used as a shorthand for if-else.
sizeof – Finds size of data type
, – Comma operator
& – Address of operator
* – Pointer operator
Unary operators
Arithmetic (* / %)
Arithmetic (+ -)
Relational
Logical
Assignment
Operators perform operations on data
C supports multiple operator types
Precedence determines order of execution
Take quizzes related to this topic and see where you stand!
Start Quiz Now