The addition operator (+) adds two operands. For example, a + b
will give the sum of a
and b
.
The subtraction operator (-) subtracts the second operand from the first. For example, a - b
will give the difference between a
and b
.
The multiplication operator (*) multiplies two operands. For example, a * b
will give the product of a
and b
.
The division operator (/) divides the first operand by the second. For example, a / b
will give the quotient of a
divided by b
.
The modulus operator (%) returns the remainder of the division of the first operand by the second. For example, a % b
will give the remainder when a
is divided by b
.
The increment operator (++) increases an integer variable's value by one. For example, a++
is equivalent to a = a + 1
.
The decrement operator (--) decreases an integer variable's value by one. For example, a--
is equivalent to a = a - 1
.
The assignment operator (=) assigns the value on the right to the variable on the left. For example, a = b
sets the value of a
to be the same as b
.
The addition assignment operator (+=) adds the right operand to the left operand and assigns the result to the left operand. For example, a += b
is equivalent to a = a + b
.
The subtraction assignment operator (-=) subtracts the right operand from the left operand and assigns the result to the left operand. For example, a -= b
is equivalent to a = a - b
.
The multiplication assignment operator (*=) multiplies the left operand by the right operand and assigns the result to the left operand. For example, a *= b
is equivalent to a = a * b
.
The division assignment operator (/=) divides the left operand by the right operand and assigns the result to the left operand. For example, a /= b
is equivalent to a = a / b
.
The modulus assignment operator (%=) takes the modulus using the two operands and assigns the result to the left operand. For example, a %= b
is equivalent to a = a % b
.