What are Operators?
Operators are symbols used to perform operations on variables and values.
Example:
int a = 10 + 5; // ‘+’ is an arithmetic operator
- Types of Operators in C:
|
Type |
Operators |
Description |
|
Arithmetic |
+, -, *, /, % |
Basic mathematical operations |
|
Relational |
==, !=, >, <, >=, <= |
Compare two values |
|
Logical |
&&, ` |
|
|
Assignment |
=, +=, -=, *=, /=, %= |
Assign values to variables |
|
Increment/Decrement |
++, — |
Increase or decrease by 1 |
|
Bitwise |
&, ` |
, ^, ~, <<, >>` |
|
Conditional (Ternary) |
condition? expr1 : expr2 |
Short form of if-else |
|
Special |
sizeof, &, * |
Size, address, and pointer ops |