Functions return values dependent upon what input they are given. Below are several links to articles about specific functions demonstrated at this site, and below those links is some further introductory explanation about functions.
Think this way....
You have a function:
You give it a value, usually a number, called the input:
The function gives you back a value, usually a number, called the output. The function matchs an output with the input:
A different input value usually, but not necessarily, matches up with a different output value:
The rules for how the input value and output value match with each other are collectively called the definition or behavior of the function. In the example above the function doubles the input to produce the output.
There is much more to the meaning of the term function than we are presenting here. The above explanation covers much of the way the term is used in mathematics. In computer languages the term function works this way when you are doing mathematics in the language, and that is what we will be doing in this section of EZ Programing Demos.
Computer languages usually have the ability to do mathematics with functions. A function used this way would have a name, an input, and an output.
Lets say we have an imaginary computer language that has a function that works this way: You give it a number, and it gives you back the absolute value of that number. So, if you gave it -3 (as input), it would return 3 (as output). Let's give this function a name; let's call it abs. A computer line like the following would print the absolute value of -3:
Points to understand:
This code would print 5:
print 2 + abs(-3);
The above links to articles present several demos illustrating many common mathematical functions found in computer languages.
Suggested next article: