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

Validate data with range and type checks

Reject values that fall outside allowed limits or do not have the required data type.

Cambridge IGCSE Computer Science 0478 · Algorithm design and problem-solving · 2026–2028 Version 6 · 7

This sequence follows Cambridge IGCSE Computer Science 0478, 2026–2028 syllabus Version 6. It covers subject content Topic 7 only. The separately published 2029–2031 syllabus is not mapped here. Practice is original, self-checked and does not award an official Cambridge grade. Full timed papers and human subject-teacher review remain outstanding.

Before you begin

  • No programming language is required. Be comfortable with place value and multiplication; each lesson introduces the computer-science notation it uses.

Work on paper. Try each question before revealing help, and explain why your method works.

Quick readiness check

Which check tests whether input is an integer?

What you will learn

  • Explain range validation
  • Explain type validation
  • Choose a suitable check for a requirement

Validation checks input acceptability

A range check tests whether a value lies between permitted limits, such as a mark from 0 to 100 inclusive. It does not prove the value is true; a mistaken but in-range mark may still pass.

Apply and check the rule

A type check tests whether the input has the required data type, such as an integer rather than text. Validation prevents unsuitable data from being accepted but cannot guarantee that a valid-looking value is accurate.

Pause and explain

A mark must be between 0 and 100. Which validation is needed?

Put the idea to work

Worked example

A system accepts an age from 0 to 120 as an integer. Name the checks needed.

Show the worked solution
  1. Check that the value is an integer.
  2. Check that it is at least 0.
  3. Check that it is at most 120.

Answer Use a type check for integer and a range check for 0–120 inclusive.

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

A temperature input must be a real number from −50 to 60. State the checks.

Give me a hint

Check type and both inclusive bounds.

Compare my reasoning
  1. Type must be real/numeric.
  2. Value must be >= −50.
  3. Value must be <= 60.

Use a numeric type check and range check −50 <= Temperature <= 60.

Look for these in your work

  • Type
  • Lower bound
  • Upper bound
2 · Independent

A code expects a whole number of books but accepts the text “five”. Why is that a type problem even though the meaning is understandable?

Give me a hint

The program's operations depend on a defined data type.

Compare my reasoning
  1. The input is text, not an integer.
  2. Arithmetic or comparison rules may not handle it as a count.
  3. Require an integer or explicitly convert recognised number words.

The value has the wrong type for a numeric count. Require an integer or implement an explicit conversion before processing.

Look for these in your work

  • Type mismatch
  • Operational risk
  • Suitable correction
3 · Transfer

A mark of 85 passes the range check 0–100 but belongs to another student. Explain what range validation proves and which separate method could detect the mix-up.

Give me a hint

Validation and verification answer different questions.

Compare my reasoning
  1. The range check proves only that 85 is an allowed value.
  2. It does not prove the mark belongs to this student.
  3. Compare with the original record using verification.

Range validation shows the value is within limits, not that it is assigned correctly. Verify the entered mark against the source record.

Look for these in your work

  • Range result
  • Accuracy limitation
  • Verification

Common mistakes

  • Calling range validation proof that a value is correct
  • Using a type check when the requirement concerns size or boundaries
Recall without your notes

What can you explain now?

What does a range check test?

Compare with the explanation

Whether a value is within allowed limits

It compares the value with minimum and maximum bounds.

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 do range and type checks differ, and what can neither prove?

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.