Operator List

1. Arithmetic Operators

Operator

Meaning

Example

Notes / Common Use

+

Addition

a + b

-

Subtraction

a - b

Also unary minus: -x

*

Multiplication

a * b

/

Division

a / b

Integer division truncates (5/2 → 2)

%

Modulo (remainder)

a % b

Only for integers: 10 % 3 == 1

++

Increment

x++ or ++x

Very common in loops

--

Decrement

x-- or --x

Same as ++ but decreases

2. Assignment Operators

Operator

Meaning

Example

Equivalent to

Very common?

=

Simple assignment

x = 5;

Yes (most used)

+=

Add and assign

x += 3;

x = x + 3;

Extremely common

-=

Subtract and assign

x -= 2;

x = x - 2;

Very common

*=

Multiply and assign

x *= 10;

x = x * 10;

Common

/=

Divide and assign

x /= 2;

x = x / 2;

Common

%=

Modulo and assign

x %= 7;

x = x % 7;

Fairly common

3. Comparison / Relational Operators (conditions, loops)

Operator

Meaning

Example

Result type

==

Equal to

a == b

int (1 or 0)

!=

Not equal

a != b

int

<

Less than

a < b

int

>

Greater than

a > b

int

<=

Less than or equal

a <= b

int

>=

Greater or equal

a >= b

int

4. Logical Operators

Operator

Meaning

Example

Short-circuits?

Most common use

&&

Logical AND

if (a && b)

Yes

Dominant in real code

`

`

Logical OR

`if (a

!

Logical NOT

!flag

Common for inverting booleans

Last updated