Start your programming journey with one of the most powerful and foundational languages — C. This comprehensive course is designed for absolute beginners as well as intermediate learners who want to build a solid understanding of programming using the C language. Whether you're preparing for college-level programming, cracking technical interviews, or planning to explore systems or embedded development, this course covers everything step-by-step. Through hands-on examples, real-world practice problems, and structured explanations, you’ll learn how to write clean and efficient C code — from your first printf() to advanced data structures and memory management.
Operators and expressions form the backbone of every computation in a C program. They allow you to perform arithmetic calculations, compare values, assign data, and even manipulate bits. In this chapter, we’ll explore each type of operator with examples and tips to master them effectively.
An operator is a symbol that tells the compiler to perform a specific mathematical or logical operation. For example, + is an arithmetic operator used for addition.
| Operator Type | Example | Use Case |
|---|---|---|
| Arithmetic | +, -, *, /, % |
Basic math operations |
| Relational | >, <, >=, <=, ==, != |
Comparing values |
| Logical | &&, ||, ! |
Combining conditions |
| Assignment | =, +=, -=, *=, /= |
Assigning values |
| Increment/Decrement | ++, -- |
Increasing or decreasing a value by 1 |
| Bitwise | &, |, ^, ~, <<, >> |
Bit-level operations |
| Ternary | condition ? expr1 : expr2 |
Short if-else |
int a = 10, b = 3;
printf("Sum = %d\n", a + b);
printf("Product = %d\n", a * b);
printf("Division = %d\n", a / b);
printf("Remainder = %d\n", a % b);
Used in conditions to compare two values.
int a = 5, b = 8;
printf("%d\n", a == b); // 0 (false)
printf("%d\n", a < b); // 1 (true)
&& → Logical AND|| → Logical OR! → Logical NOTint a = 1, b = 0;
printf("%d\n", a && b); // 0
printf("%d\n", a || b); // 1
int x = 5;
x += 3; // Same as x = x + 3;
printf("%d\n", x); // 8
int a = 10;
a++; // post-increment
++a; // pre-increment
a--; // post-decrement
int a = 10, b = 20;
int max = (a > b) ? a : b;
printf("Max is %d\n", max);
Operators are evaluated in a specific order called precedence. For example, * and / have higher precedence than + and -.
() [] -> . ++ --+ - ! ~ ++ --* / %+ -< <= > >=== !=&&||= += -= *= /=,#include <stdio.h>
int main() {
int a = 10, b = 5;
printf("Addition: %d\n", a + b);
printf("Is a > b? %d\n", a > b);
printf("Logical Check: %d\n", (a > 0) && (b < 10));
return 0;
}
In the next chapter, we’ll study Conditional Statements in C, including if, else, else if, and switch statements — crucial for decision making.