Integer CS Thinking Example 3

Follow the full solution, then compare it with the other examples linked below.

Example 3

easy
What are the results of: (a) 25 MOD 7, (b) 100 DIV 3, (c) 8 MOD 2?

Solution

  1. 1
    Step 1: (a) 25 รท 7 = 3 remainder 4, so 25 MOD 7 = 4. (b) 100 รท 3 = 33 remainder 1, so 100 DIV 3 = 33.
  2. 2
    Step 2: (c) 8 รท 2 = 4 remainder 0, so 8 MOD 2 = 0 (8 is even).

Answer

(a) 4, (b) 33, (c) 0.
MOD = 0 tells us a number is evenly divisible. This is commonly used to check if a number is even (n MOD 2 == 0) or to cycle through values.

About Integer

A data type that represents whole numbers (positive, negative, or zero) without decimal points. Integers are stored exactly in memory and support arithmetic operations like addition, subtraction, multiplication, and integer division.

Learn more about Integer โ†’

More Integer Examples