C Operators

C Operators (Complete Guide: Beginner → Advanced)
In C language, operators are special symbols that perform operations on variables and values.
They are used in calculations, conditions, logic, memory handling, and bit manipulation—making them fundamental for all C programs and interviews.
What Are Operators in C?
Operators tell the compiler what operation to perform on operands (values or variables).
Types of Operators in C
C operators are broadly divided into the following categories:
Arithmetic Operators
Relational Operators
Logical Operators
Assignment Operators
Increment / Decrement Operators
Bitwise Operators
Conditional (Ternary) Operator
Special Operators
Arithmetic Operators
Used for mathematical calculations.
| Operator | Meaning |
|---|---|
+ | Addition |
- | Subtraction |
* | Multiplication |
/ | Division |
% | Modulus (remainder) |
Example
%works only with integers
Relational Operators
Used to compare values (result is true/false).
| Operator | Meaning |
|---|---|
== | Equal to |
!= | Not equal |
> | Greater than |
< | Less than |
>= | Greater or equal |
<= | Less or equal |
Logical Operators
Used to combine conditions.
| Operator | Meaning |
|---|---|
&& | Logical AND |
| ` | |
! | Logical NOT |
- Uses short-circuit evaluation
Assignment Operators
Used to assign values.
| Operator | Meaning |
|---|---|
= | Assign |
+= | Add & assign |
-= | Subtract & assign |
*= | Multiply & assign |
/= | Divide & assign |
%= | Modulus & assign |
Increment & Decrement Operators
| Operator | Meaning |
|---|---|
++ | Increment |
-- | Decrement |
Pre vs Post
- Very important for loops & interviews
Bitwise Operators (Advanced)
Operate on bits.
| Operator | Meaning |
|---|---|
& | AND |
| ` | ` |
^ | XOR |
~ | NOT |
<< | Left shift |
>> | Right shift |
- Used in embedded systems & low-level programming
Conditional (Ternary) Operator
Syntax
Example
- Short form of
if...else
Special Operators
sizeof
Comma Operator
Address-of (&) and Dereference (*)
Operator Precedence (Very Important)
Example:
*has higher precedence than+- Use parentheses
()to avoid confusion.
Common Mistakes
- Using
=instead of== Confusing logical (&&) and bitwise (&)- Integer division mistakes
- Ignoring operator precedence
Interview Questions (Must Prepare)
Difference between
=and==Logical vs bitwise operators
What is short-circuit evaluation?
Pre vs post increment
What does
sizeofreturn?Operator precedence example
Real-Life Use Cases
Calculations & analytics
Conditions & validations
Loop control
Bit manipulation (embedded)
Memory access (pointers)
Summary
- Operators perform actions on data
- C has 8 major categories of operators
- Logical & relational operators control flow
- Bitwise operators work at bit level
- Crucial for DSA, system programming & interviews
