This study notes covers Deep Dive: DIV and MOD within Operators for GCSE Computer Science. Revise Operators in Programming for GCSE Computer Science with 15 exam-style questions and 8 flashcards. This topic appears less often, but it can still be a useful differentiator on mixed-topic papers. It is section 4 of 6 in this topic. Use this study notes to connect the idea to the wider topic before moving on to questions and flashcards.
Topic position
Section 4 of 6
Practice
15 questions
Recall
8 flashcards
Deep Dive: DIV and MOD
DIV (integer division) - divides and throws away the remainder:
- 17 DIV 5 = 3 (17 ÷ 5 = 3 remainder 2)
- 10 DIV 3 = 3
MOD (modulus) - gives only the remainder:
- 17 MOD 5 = 2
- 10 MOD 3 = 1
Common uses:
- Check if even:
number MOD 2 == 0 - Get last digit:
number MOD 10 - Cycle through 0-9:
counter MOD 10