Integers
This lesson explains fundamental arithmetic operations in general and provides background knowledge related to the integer data type.
We'll cover the following...
Arithmetic operations #
The basic arithmetic operations are addition, multiplication, division and subtraction. Arithmetic operations allow us to write much more useful programs.
Before going further, let’s have a look at the summary of arithmetic operations:
Most of those operators have counterparts that have an =
sign attached: +=
, -=
, *=
, /=
, %=
, and ^^=
. These operators assign the result of the operation to the variable on the left-hand side.
variable += 10;
This expression adds 10
to the value of the variable
and assigns the result to variable
. After the operation, the value of the variable
would be incremented by 10
. It is the equivalent of the following expression:
variable = variable + 10;
Although arithmetic operations are a part ...