You are here

Overview of Arithmetic Assignment

19 January, 2016 - 11:41

The five arithmetic assignment operators are a form of short hand. Various textbooks call them "com pound assignment operators" or "combined assignment operators". Their usage can be explained in terms of the assignment operator and the arithmetic operators. In the table we will use the variable age and you can assume that it is of integer data type.

Table 4.2 Arithmetic assignment

Arithmetic assignment examples:

Equivalent code:

age += l4;

age = age + l4;

age -= l4;

age = age -l4;

age *= 14;

age = age * 14;

age /= 14;

age = age / 14;

age %= 14;

age = age % 14;