Module 05: Operators, Expressions & Bitwise Manipulation

Duration: 4.5 Hours • Core Logic
1. Operator Categories 1 / 4

Arithmetic, Relational & Logical Operators

Integer division truncation and Short-Circuit evaluation

Operators perform computations on operands. Understanding truncation and short-circuit evaluation is essential:

⚠️
Integer Division Truncates Towards Zero
In C, 5 / 2 evaluates to 2 (the fractional part .5 is discarded). To get a floating-point result, at least one operand must be a float or explicitly cast: 5.0 / 2 == 2.5 or (double)5 / 2 == 2.5.
short_circuit.c
int a = 0;
int b = 10;

// Short-circuit evaluation: In (A && B), if A is false, B is NEVER evaluated!
if (a != 0 && ++b > 10) {
    // Will not execute
}
printf("b is still: %d\\n", b); // Prints 10 (b was not incremented!)