Use DIV, MOD, ROUND and RANDOM
Apply the syllabus library routines and check what each one returns.
Exam scope and assessment notes
This sequence follows Cambridge IGCSE Computer Science 0984, 2026–2028 syllabus Version 4. It covers section 8.1 (Programming concepts) only. Pseudocode examples use the published Cambridge format; the separate 2029–2031 syllabus is not mapped here. Practice is original, self-checked and does not award an official Cambridge grade. Full timed papers, a browser-based programming workspace and human subject-teacher review remain outstanding. Cambridge states that 0984 has the same 2026–2028 subject content as 0478, with 9–1 grading. In June and November, Cambridge lists 0984 in Administrative zone 3 and for centres in Oman and the UAE. Confirm availability for your centre and exam series with Cambridge International. The separately published 2029–2031 syllabus changes to Python 3 only and removes pseudocode; this 2026–2028 route does not cover those changes.
Before you begin
- Be comfortable following an ordered algorithm and tracing variable values. Each lesson introduces the Cambridge pseudocode form it uses.
Work on paper. Try each question before revealing help, and explain why your method works.
Quick readiness check
What does ROUND(3.141, 2) return?
What you will learn
- Use DIV and MOD for integer division
- Round a real value to a stated number of places
- Use RANDOM within its documented range
Integer routines support grouping and remainders
DIV(A,B) returns the whole-number quotient with the fractional part discarded. MOD(A,B) returns the remainder. Both identifiers are INTEGER values and the divisor must not be zero.
Use MOD to test divisibility: MOD(Number,2)=0 means an even integer. Use DIV to find how many complete groups fit.
ROUND and RANDOM return calculated values
ROUND(Value, Places) rounds a real number to the specified number of decimal places. RANDOM() returns a real value from 0 to 1 inclusive.
To make an integer from 0 to 6, the syllabus example uses ROUND(RANDOM() * 6, 0). Be careful: this range includes 0 and 6.
Pause and explain
What range can ROUND(RANDOM() * 6, 0) produce?
Worked example
Find the number of complete boxes and leftover objects when 29 objects are packed 6 per box.
Show the worked solution
- Use DIV(29,6) for complete boxes.
- Use MOD(29,6) for leftovers.
- Check 6 × 4 + 5 = 29.
Answer DIV(29,6) = 4 complete boxes; MOD(29,6) = 5 objects left.
Try a topic test
Choose Easy, Normal or Difficult. Save your answers and open worked review after finishing.
Test this topic →From guided practice to a new situation
Write your answer and reasoning first. Use a hint only if you are stuck. The model solution is for self-checking; your written work is not automatically marked.
Calculate DIV(31,7) and MOD(31,7), then check the relationship.
Give me a hint
The quotient and remainder satisfy 7q + r = 31.
Compare my reasoning
- Seven fits in 31 four times.
- 4 × 7 = 28, leaving 3.
- Check 28 + 3 = 31.
DIV(31,7) = 4 and MOD(31,7) = 3.
Look for these in your work
- Quotient
- Remainder
- Check
What does ROUND(18.276, 1) return?
Give me a hint
Look at the second digit after the decimal point.
Compare my reasoning
- Keep one decimal place: 18.2.
- The next digit is 7, so round upward.
- The result is 18.3.
18.3.
Look for these in your work
- Place selected
- Rounding direction
A program needs a random whole number from 1 to 6 but uses ROUND(RANDOM()*6,0). What range does it actually allow, and name a correction idea.
Give me a hint
Check both endpoints and note RANDOM can be 0.
Compare my reasoning
- The expression can produce 0 through 6.
- The desired range has six outcomes and starts at 1.
- Shift or rescale the random result, then test every boundary.
It can produce 0–6; transform the result to 1–6 and verify that 0 is impossible and 6 remains possible.
Look for these in your work
- Actual range
- Boundary-focused change
Common mistakes
- Confusing DIV and MOD
- Dividing by zero
- Assuming RANDOM() returns only whole numbers
- Assuming the ROUND example starts at 1
What can you explain now?
What does MOD(20,6) return?
Compare with the explanation
2
Six fits into 20 three times with remainder 2.
After trying it yourself, choose your next review. This is your self-assessment.
Your review choice appears on Today. Sign in to sync it across devices.
Make it stick
How can MOD help decide whether an integer is even?
If you needed the solution, close it and solve the problem again from a blank page. A correct answer is stronger when you can explain the reason for each step.