Procedimientos
A PROCEDURE is a named block
- A procedure is a named set of steps you run with
CALL. - Define it once, then call it as many times as you like.

PROCEDURE Greet
OUTPUT "Hello!"
ENDPROCEDURE
CALL Greet
CALL Greet // → Hello! (twice)
Parameters pass data in
- Put a parameter in brackets to send a value in.
PROCEDURE Greet(Name : STRING)
OUTPUT "Hi, ", Name
ENDPROCEDURE
CALL Greet("Ada") // → Hi, Ada
CALL lo ejecuta, luego regresa
CALL salta al procedimiento, ejecuta sus pasos y luego regresa a la siguiente línea.
A parameter is a copy
- A parameter is a copy of the value you passed in.
- Changing it inside the procedure does not change the caller's variable.
- To get an answer back, use a FUNCTION and
RETURNit (next lesson).

FUNCTION Double(Number : INTEGER) RETURNS INTEGER
RETURN Number * 2
ENDFUNCTION
DECLARE Value : INTEGER
Value ← 5
OUTPUT Double(Value) // → 10
Local and global
- A variable declared in the main program is global. A procedure can read it and change it.
- A variable declared inside the procedure is local. It hides a global of the same name, and it disappears when the call ends.
- A parameter is local too. It is a copy, so changing the parameter does not change the caller's variable.
DECLARE Total : INTEGER
Total ← 10
PROCEDURE ShowLocal
DECLARE Total : INTEGER
Total ← 3
OUTPUT Total // → 3, the local one
ENDPROCEDURE
CALL ShowLocal
OUTPUT Total // → 10, the global one
Watch out
- You must write
CALLbefore a procedure's name — but never before a function's. - A procedure does not return a value through its name; a function does. A procedure can still change a global variable.
- (
BYREFmakes a parameter the real variable rather than a copy. It is in the AS 9618 guide, not in the IGCSE 0478 syllabus for 2026–2028, so do not use it in Paper 2.)
Common mistakes
PROCEDURE Name(...) ... ENDPROCEDURE; run it withCALL Name(...).- A procedure does a job but returns no value.
Now you try
- Define a procedure, then
CALLit. - Press Check answer to test it.
Dificultad 3/5 · 200 monedas + un pequeño bono en el primer intento de hoy
Define un PROCEDURE Greet que imprima Hello!, luego CALL dos veces (para que Hello! se imprima en dos líneas).
Haz clic en Ejecutar para ver la salida aquí.
Dificultad 3/5 · 200 monedas + un pequeño bono en el primer intento de hoy
Define PROCEDURE Greet(Name : STRING) que muestre Hi, seguido del nombre, luego CALL Greet("Ada"). La salida debe ser Hi, Ada.
Haz clic en Ejecutar para ver la salida aquí.
Dificultad 3/5 · 200 monedas + un pequeño bono en el primer intento de hoy
Define FUNCTION Double(Number : INTEGER) RETURNS INTEGER que devuelva el doble de Number. Establece Value en 5, luego muestra Double(Value) (debería ser 10).
Haz clic en Ejecutar para ver la salida aquí.
Dificultad 3/5 · 200 monedas + un pequeño bono en el primer intento de hoy
Total es una variable global INTEGER inicializada en 10. Dentro de PROCEDURE AddFive, suma 5 a ese mismo Total. Después de la llamada, muestra Total (es 15).
Haz clic en Ejecutar para ver la salida aquí.