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

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