<<< Variable Naming Convention | Index | Arithmetic Operators, cont. >>> |
// integer arithmetic int x = 14; int y = 8; int result1 = x + y; // result1 = 22 int result2 = x - y; // result2 = 6 int result3 = x * y; // result3 = 112 int result4 = x / y; // result4 = 1
Note how dividing an integer by an integer produces an integer quotient and the remainder is lost.
<<< Variable Naming Convention | Index | Arithmetic Operators, cont. >>> |