Integer Division: DIV (Quotient) & MOD (Remainder)

In computer science, integer arithmetic frequently requires decomposing divisions into two distinct components: the whole number of times a divisor fits into a dividend, and the leftover remainder.


1. The Distinction Between /, DIV, and MOD

Operator

Full Name

Purpose

Example (17 and 5)

/

Real Division

Divides and returns a floating-point REAL quotient with decimals.

17 / 5 = 3.4

DIV

Integer Division

Returns the integer quotient, discarding any fractional remainder.

17 DIV 5 = 3

MOD

Modulo Division

Returns the remainder left over after integer division.

17 MOD 5 = 2

Fundamental Mathematical Identity:

$$\text{Dividend} = (\text{Dividend} \text{ DIV } \text{Divisor}) \times \text{Divisor} + (\text{Dividend} \text{ MOD } \text{Divisor})$$
$$17 = (3 \times 5) + 2$$

2. Common Exam Applications in Cambridge Paper 2

1. Unit & Time Conversions

Transforming flat units (e.g. seconds, cents, grams) into compound units (e.g. hours/minutes/seconds, dollars/cents, kilograms/grams):

Hours <- TotalSeconds DIV 3600
RemainingSeconds <- TotalSeconds MOD 3600
Minutes <- RemainingSeconds DIV 60
Seconds <- RemainingSeconds MOD 60

2. Odd and Even Number Determination

Any integer N is even if and only if dividing by 2 leaves zero remainder:

IF Number MOD 2 = 0 THEN
    OUTPUT "Number is Even"
ELSE
    OUTPUT "Number is Odd"
ENDIF

3. Extracting and Stripping Digits

  • Extract units digit: Units <- Value MOD 10 (e.g. 247 MOD 10 = 7)
  • Strip units digit: Value <- Value DIV 10 (e.g. 247 DIV 10 = 24)

AI Socratic Tutor

All-Access
Sign in or create an account. AI Tutor is an All-Access benefit.
Sign Up

Need guidance? Ask a question or use the hint below.

AI Socratic Tutor is an All-Access Benefit

Unlock step-by-step Socratic hints, algorithm trace table walkthroughs, and error diagnostics for every Cambridge exercise.

You're chatting with an AI tutor, not a person. AI can make mistakes, so double-check its answers.

Exam-Style Check: Distinguish DIV and MOD Operations

• Multiple Choice
+25 XP
Question

What are the evaluated results of 29 DIV 6 and 29 MOD 6 in Cambridge pseudocode?

All-Access Required

Interactive exercises for Module 2 and beyond require an active plan.