Siksha Sarovar

Siksha Sarovar (sikshasarovar.com) is a free educational web application that helps students in India learn programming and prepare for academic and competitive exams. The platform offers structured coding courses (C, C++, Python, Java, HTML, CSS, PHP, Power BI, AI, Machine Learning, Data Science), complete university curriculum notes for BCA/MCA students with previous year question papers, Class 10 and Class 12 CBSE/HBSE school notes, and dedicated preparation material for SSC, UPSC, Banking, Railway and other government exams. Browsing the site is completely free and requires no account. Users may optionally sign in with Google solely to save their learning progress, quiz scores and personal preferences across devices.

Privacy Policy | Terms of Service | Contact Siksha Sarovar | About Siksha Sarovar

v4.0.9 · PWA
Siksha Sarovar logo
Siksha Sarovar
Your Learning Universe

Siksha Sarovar is a free e-learning platform for coding courses, BCA university notes and competitive exam preparation. Optional Google sign-in saves your learning progress across devices.

Initializing knowledge base…
Compiling modules 0%

Unit 1 — Operators in C

Lesson 4 of 32 in the free C Language notes on Siksha Sarovar, written by Rohit Jangra.

Operators in C

An operator is a symbol that tells the compiler to perform a specific operation on operands.

---

Categories of Operators

1. Arithmetic Operators

OperatorMeaningExampleResult
+Addition5 + 38
-Subtraction5 - 32
*Multiplication5 * 315
/Division5 / 22 (integer)
%Modulus5 % 21

2. Relational Operators

OperatorMeaningExample
==Equal toa == b
!=Not equal toa != b
>Greater thana > b
<Less thana < b
>=Greater or equala >= b
<=Less or equala <= b

3. Logical Operators

OperatorMeaningExample
&&Logical ANDa > 0 && b > 0
``Logical OR`a > 0b > 0`
!Logical NOT!a

4. Assignment Operators

a = 5;    /* simple assignment */
a += 3;   /* a = a + 3 */
a -= 2;   /* a = a - 2 */
a *= 4;   /* a = a * 4 */
a /= 2;   /* a = a / 2 */
a %= 3;   /* a = a % 3 */

5. Increment and Decrement

int a = 5;
printf("%d", ++a);  /* pre-increment: prints 6, a = 6 */
printf("%d", a++);  /* post-increment: prints 6, a = 7 */
printf("%d", --a);  /* pre-decrement: prints 6, a = 6 */
printf("%d", a--);  /* post-decrement: prints 6, a = 5 */

6. Bitwise Operators

OperatorMeaningExample
&Bitwise AND5 & 3 = 1
``Bitwise OR`53` = 7
^Bitwise XOR5 ^ 3 = 6
~Bitwise NOT~5 = -6
<<Left shift5 << 1 = 10
>>Right shift5 >> 1 = 2

7. Conditional (Ternary) Operator

int max = (a > b) ? a : b;
/* If a > b, max = a, else max = b */

8. sizeof Operator

printf("%zu", sizeof(int));    /* prints 4 */
printf("%zu", sizeof(char));   /* prints 1 */

---

Operator Precedence (High to Low)

PriorityOperators
Highest(), [], ->, .
++, --, !, ~, sizeof, * (unary), & (unary)
*, /, %
+, -
<<, >>
<, <=, >, >=
==, !=
&, ^, ``
&&, ``
?:
Lowest=, +=, -= etc.