Learn in your language
Skip to content
IGCSE · Cambridge (CIE) · 0478

Use DIV, MOD, ROUND and RANDOM

Apply the syllabus library routines and check what each one returns.

Cambridge IGCSE Computer Science 0478 · Programming · 2026–2028 Version 6 · 8.1
Exam scope and assessment notes

This sequence follows Cambridge IGCSE Computer Science 0478, 2026–2028 syllabus Version 6. 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.

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?

Put the idea to work

Worked example

Find the number of complete boxes and leftover objects when 29 objects are packed 6 per box.

Show the worked solution
  1. Use DIV(29,6) for complete boxes.
  2. Use MOD(29,6) for leftovers.
  3. 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.

1 · Guided

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
  1. Seven fits in 31 four times.
  2. 4 × 7 = 28, leaving 3.
  3. Check 28 + 3 = 31.

DIV(31,7) = 4 and MOD(31,7) = 3.

Look for these in your work

  • Quotient
  • Remainder
  • Check
2 · Independent

What does ROUND(18.276, 1) return?

Give me a hint

Look at the second digit after the decimal point.

Compare my reasoning
  1. Keep one decimal place: 18.2.
  2. The next digit is 7, so round upward.
  3. The result is 18.3.

18.3.

Look for these in your work

  • Place selected
  • Rounding direction
3 · Transfer

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
  1. The expression can produce 0 through 6.
  2. The desired range has six outcomes and starts at 1.
  3. 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
Recall without your notes

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.

Keep learning Computer Science

Course scope and assessment

165 original lessons map the listed objectives across all 10 main topics in the 2026–2028 Version 6 syllabus, with worked explanations and guided, independent and transfer practice. This is mapped teaching coverage, not proof of full exam readiness. Three earlier starter lessons remain available but are not counted as syllabus-mapped teaching. Practical programming experience in an executable browser workspace, full timed-paper practice, human subject-teacher review and the separate 2029–2031 syllabus remain outstanding. Practice is self-checked and does not award an official Cambridge grade.

StudyForA · Learn with understanding

Original teaching content and links to official sources. Check your exam year and qualification before using a resource.