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

Return values from functions

Define a typed function, return a result and use it as part of a larger expression.

Cambridge IGCSE Computer Science 0984 · Programming · 2026–2028 Version 4 · 0984 (9–1) · 8.1
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 RETURN do inside a function?

What you will learn

  • Declare function parameters and return type
  • Use RETURN to provide one value
  • Call a function inside an expression

A function has a declared result type

Write FUNCTION Name(parameters) RETURNS Type and close it with ENDFUNCTION. Parameters are typed inputs; the RETURNS type tells the caller what value will be produced.

Use RETURN in the function body to send one result back. The value should match the declared return type.

Use the returned value at the call site

A function call is an expression, so it can appear on the right side of an assignment or inside OUTPUT. Do not write CALL before a function.

A function should have a clear result for every path. Check conditions so that each possible input reaches a RETURN statement.

Pause and explain

Which is a valid way to use a function named DoubleValue?

Put the idea to work

Worked example

Create a function that returns the greater of two integer values.

Show the worked solution
  1. Declare two INTEGER parameters and an INTEGER return type.
  2. Compare the values with IF.
  3. Return the larger one and use the call in an assignment.

Answer FUNCTION Maximum(A : INTEGER, B : INTEGER) RETURNS INTEGER IF A > B THEN RETURN A ELSE RETURN B ENDIF ENDFUNCTION Largest ← Maximum(7, 4) // 7

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 function adds 4 and 5 and returns an INTEGER. What value does Result ← Add(4,5) store?

Give me a hint

Follow the returned expression.

Compare my reasoning
  1. Add returns 4 + 5.
  2. The function result is 9.
  3. The assignment stores that value in Result.

Result is 9.

Look for these in your work

  • Return evaluated
  • Assignment traced
2 · Independent

State the header for a function called IsEven that receives an INTEGER and returns a BOOLEAN.

Give me a hint

The result is a logical value.

Compare my reasoning
  1. Name the parameter Number : INTEGER.
  2. Write RETURNS BOOLEAN.
  3. Close the definition with ENDFUNCTION after its body.

FUNCTION IsEven(Number : INTEGER) RETURNS BOOLEAN.

Look for these in your work

  • Parameter typed
  • Return type stated
3 · Transfer

A function returns a REAL for positive input but has no return in its ELSE branch. What problem can this cause?

Give me a hint

Check that every possible path has a defined function result.

Compare my reasoning
  1. A non-positive input may reach the ELSE branch.
  2. The caller expects a REAL value.
  3. Define a returned result or handle the input explicitly in that branch.

The function may finish without the required value; provide a valid REAL result or an explicit handling path for every input.

Look for these in your work

  • Missing path identified
  • Return coverage proposed

Common mistakes

  • Omitting the RETURNS type
  • Using CALL for a function
  • A branch that reaches the end without returning a value
Recall without your notes

What can you explain now?

How is a function's value used by its caller?

Compare with the explanation

As part of an expression

The returned value replaces the function call in an expression.

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

Why is CALL not used when a function is part of an expression?

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 (9-1)

Course scope and assessment

165 original lessons map the listed objectives across all 10 main topics in the 2026–2028 Version 4 syllabus. Cambridge states that 0984 has the same subject content as 0478, with 9–1 grading. Three retained introductory lessons remain available but are not counted as syllabus-mapped teaching. The 2023–2025 syllabus remains unmapped. The separately published 2029–2031 syllabus changes to Python 3 only and removes pseudocode; this 2026–2028 route does not cover those changes. 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. Practical programming in an executable browser workspace, full timed-paper practice and human subject-teacher review 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.