Sign InCreate Account

EditorProjectsPseudocode TutorPractice QuestionsCode ConverterCode GeneratorFlowchartsUpgrade to Pro

Master Pseudocode with Pro

Get unlimited access to the AI Tutor, Code Generator, and Converters. Plus, enjoy an ad-free experience.

Upgrade Now

Functions, Procedures, and Subroutines in Pseudocode

When you first begin learning to program, it is common to write scripts sequentially, moving from top to bottom in one long file. However, as programs grow larger and more complex, this approach rapidly becomes messy, difficult to read, and incredibly hard to maintain. To solve this, developers rely on subroutines.

A subroutine is a named, self-contained block of code designed to perform a specific, isolated task. By wrapping a set of instructions into a subroutine, you adhere to the fundamental programming principle known as DRY (Don't Repeat Yourself). Instead of duplicating the same ten lines of code every time you need to authenticate a user or sort an array, you write those lines once inside a subroutine and simply call its identifier whenever required.

In pseudocode, subroutines are generally broken down into two distinct categories: Functions and Procedures. In this comprehensive guide, we will first explore the spec-agnostic core concepts of subroutines, ensuring you understand exactly how they operate. Then, we will break down the exact syntax variations and formatting rules required by major exam boards, including AQA, OCR, and Cambridge (CIE).

Table of Contents

Core Concepts: Functions vs Procedures
Defining a ProcedureDefining a FunctionParameters and ArgumentsCalling Subroutines
Syntax Variations by Exam BoardConclusion

Core Concepts: Functions vs. Procedures

Regardless of the programming language or exam board specification you are using, the underlying logic of subroutines remains the same. The most critical distinction you need to understand is the behavioral difference between a function and a procedure.

Defining a Procedure

A procedure is a block of code that executes a set of commands to perform an action, but it does not return a value back to the main program. You can think of it as an action command. For example, a subroutine that clears the screen, outputs a welcome menu, or writes data to a text file is a procedure.

Loading...

Defining a Function

A function also executes a set of commands, but its primary purpose is to calculate and always return a single value back to the point where it was called. This is done using a Return statement. Once the return statement is hit, the function ends immediately and gives data back to the main program.

Loading...

Parameters and Arguments

Subroutines often need data from the main program to work properly. The variables passed into a subroutine are called parameters (or arguments). When defining a subroutine, you declare parameters inside parentheses. There are two distinct ways to pass parameters:

  • Pass By Value (BYVAL): A copy of the data is sent to the subroutine. If the subroutine modifies this parameter, it only affects the local copy. The original variable in the main program remains unchanged.
  • Pass By Reference (BYREF): The actual memory address of the variable is sent. The subroutine operates directly on the original variable. If the subroutine changes the value of the parameter, the original variable in the main program is permanently altered.
Loading...

Calling Subroutines

Defining a subroutine does not run it. To execute the code inside, you must call the subroutine from your main program. Procedures are usually called as standalone statements, while functions are usually called as part of an assignment or expression so you can capture the returned value.

Loading...

Syntax Variations by Exam Board

Because pseudocode is not an executable language with strict global rules, different educational boards use distinct syntax and keywords to represent the core concepts we just discussed.

AQA Pseudocode Standard

The AQA specification favors simplicity and does not use separate keywords for functions and procedures.

  • Keyword: Use the universal keyword SUBROUTINE to open the block, followed by ENDSUBROUTINE to close it.
  • Implicit Distinction: If your subroutine contains a RETURN statement, AQA implicitly considers it a function. If it doesn't, it's a procedure.
  • Data Types: AQA does not require explicit data type declarations for parameters.
Loading...

OCR Pseudocode Standard

Unlike AQA, OCR explicitly differentiates the blocks using specific keywords and prefers lowercase conventions.

  • Keywords: Use function / endfunction for functions, and procedure / endprocedure for procedures.
  • Calling: To call a procedure, you simply state its identifier (or use the optional call keyword). Functions are assigned to variables.
  • Parameters: OCR assumes parameters are passed by value. If you need to pass by reference, explicitly state byRef next to the parameter.
Loading...

Cambridge (CIE / 9618) Standard

The Cambridge International (CIE) standard is the most robust and requires strict data typing, heavily resembling languages like Pascal or Visual Basic.

  • Return Types: You must declare the return data type of a function using RETURNS <data type> at the end of the definition line.
  • Parameter Typing: Parameters must have their data types explicitly declared (e.g., Number1: INTEGER).
  • Calling Procedures: You must use the CALL keyword to execute a procedure.
  • BYVAL/BYREF: You use uppercase BYVAL and BYREF keywords to specify how parameters are passed. If omitted, BYVAL is assumed.
Loading...

Conclusion

Understanding the difference between functions and procedures is a critical step in becoming a proficient programmer. By mastering subroutines, you ensure your code adheres to the DRY principle, remains modular, and is significantly easier to test and maintain.

While the core logic of passing parameters by value or reference, and returning data back to the main program remains universal, always ensure you adapt your syntax—like adding explicit data types for CIE or using the universal SUBROUTINE keyword for AQA—to match the specific requirements of your exam board.

Read Our Guide on
Variables
in Pseudocode


Ready to practice? Try our editor.

Give our pseudocode editor a go today for free - with a built-in compiler, tools to convert pseudocode to code, and project saving, PseudoEditor makes writing pseudocode easier than ever!

Start coding now

Product

For SchoolsOverviewFeaturesFAQ

© 2026 PseudoEditor. All rights reserved.