1/13/00
COM1100 Winter2000 Yuhong Yin Northeastern University
5
Integer Division
nIn C++, the fractional part of the result obtained when dividing two integers is dropped(truncated)
n15 / 2 = 7  // instead of 7.5
n15.0 / 2 = 7.5
n15 / 2.0 = 7.5
nModulus Operator (%) : capture the remainder of an integer division
n 9 % 4 = 1
n17 % 3 = 2
n14 % 2 = 0
nThe Modulus Operator can be used only with integers