Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Subroutine: Difference between revisions

From Coderwiki
new: info, parameters, types
 
replace link to Return with Function return
 
Line 10: Line 10:
== Types of subroutines ==
== Types of subroutines ==


* [[Function]] - a subroutine which '''does''' [[return]] a [[value]].
* [[Function]] - a subroutine which '''does''' [[Function return|return]] a [[value]].
* [[Procedure]] - a subroutine which '''does not''' [[Function return|return]] a [[value]].
* [[Procedure]] - a subroutine which '''does not''' [[Function return|return]] a [[value]].

Latest revision as of 21:36, 15 August 2025

A subroutine is a code block in a separate part of the source code.

This code block can be called, or 'invoked', and calling the subroutine will run the code in the code block.

Subroutines can take in parameters. These parameters give the subroutine more information about how to run and what values to act upon.

For example, a function addOne which simply returns the integer one above the value of the parameter we pass in, could take in an integer called num as a parameter.

Types of subroutines

edit edit source