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

Return Value

From Groundhog Learning
Revision as of 15:57, 21 October 2025 by Groundhog (talk | contribs) (Updated via bot)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

The result a function gives back after it runs.

Details

Some functions perform a task and give back a value that can be used later in the program.

For example, a function that adds two numbers might return their sum:

🤖 Pseudocode

function add(a, b):
    return a + b

This function accepts two parameters a and b and returns the sum of their values.

When the program calls the function, it receives the returned value and can use it as needed.

A common use is storing it in a variable or using it in an expression:

🤖 Pseudocode

int sum = add(1, 2); # Declares a variable with the function return value (3)

Related Concepts

References