Concept
How do functions work in programming languages?
ComputerScienceOne / Functions
"In programming languages, a function (sometimes called subroutine or procedure) can take multiple inputs and produce one output value. We’ve already seen some examples of these functions. For example, most languages provide a math library that you can use to evaluate the square root or sine of a value x . We’ve also seen some functions with multiple input values such as the “power” function that allows you to compute f ( x, y ) = x y . Finally, the main entry point to many programs is defined by a main function. More formally, a function is a sequence of instructions (code) that is packaged into a unit that can be reused. A function performs a specific task: given a number of inputs, it executes some sequence of operations (executes some code) and “returns” (outputs) a result. The output can be captured into a variable or used in an expression by whatever code invoked or “called” the function."
Related Ideas
- How do you call a function in C?ComputerScienceOne · Calling Functions
- How do you call functions in C?ComputerScienceOne · Organizing Functions
- How do header and source files organize functions in C?ComputerScienceOne · Calling Functions
- How do you call a function in PHP?ComputerScienceOne · Calling Functions
- What are the key features of functions in PHP?ComputerScienceOne · Declaring Functions