← All Paper 2 problems·All lessons
Paper 2 scenario practice

Temperature conversion using a function

The scenario
A weather app needs to convert Celsius to Fahrenheit. The developer wants: 1. A FUNCTION called CelsiusToFahrenheit that takes ONE parameter (a temperature in Celsius, REAL) and RETURNS the converted Fahrenheit value (REAL). - Conversion formula: F = C × 9/5 + 32. 2. A main program that: - Reads 5 Celsius temperatures (one at a time). - For each, calls the function and outputs the original Celsius value AND the converted Fahrenheit value. Write a program in pseudocode (or a high-level language of your choice). Marks will be awarded for correct function declaration, parameter handling, the RETURN statement, and proper integration with the main program.
Lessons that prepare for this: Lesson 19 — Pseudocode and flowcharts · Lesson 23 — Programming concepts · Lesson 25 — Subroutines
Marking scheme — total 15 marks
Cambridge IGCSE 0478 Paper 2
  • 3
    Function header: FUNCTION CelsiusToFahrenheit(c : REAL) RETURNS REAL — declares the function name, the parameter with its type, and the return type.
  • 3
    Function body and RETURN: Inside the function: compute fahrenheit ← c * 9 / 5 + 32 (or directly RETURN c * 9 / 5 + 32). The RETURN statement is essential — without it the function produces no value.
  • 3
    Main program loop: FOR loop running exactly 5 times. INPUT the Celsius value each iteration.
  • 4
    Function call and output: CALL the function with the input value (or assign its return value to a variable). OUTPUT both the Celsius value and the returned Fahrenheit value, with labels making it clear which is which.
  • 2
    Program structure and naming: FUNCTION/ENDFUNCTION paired; sensible parameter and variable names; main program reads top-to-bottom.
Hints — reveal one at a time, only if stuck
Your pseudocode workspace
1 line