Loading...
Loading...
Loading Curriculum...
Loading Subject...
Loading Topic...
Loading Lesson...
Loading Lab...
Arithmetic operators perform mathematical calculations on numeric operands.
+Addition5 + 3 = 8-Subtraction10 - 4 = 6*Multiplication6 * 7 = 42/Division15 / 4 = 3 (int)%Modulus17 % 5 = 2int a = 15 / 4; // 3 (truncated) double b = 15.0 / 4; // 3.75
When both operands are integers, the result is truncated. Cast to double for decimal results.
// Check even/odd if (n % 2 == 0) // even // Wrap around int idx = i % size;
The modulus operator is essential in DSA — used for hashing, cyclic indexing, and modular arithmetic.