Function is a unit of block code that executes a specific task. It is a type of procedure organized to produce a single result. In a word, the function takes in data - an input calculates it and gives back a result - output. The function itself is a program fragment that produces a specified effect. Once the function is set, it can be used over and over again. Depending on the purpose the function remains more or less fixed.
With the help of functions, it’s possible to build the entire software apps. A great code structure includes blocks of statements that perform a particular task. The act of using the function sounds as ‘calling the function’. The execution of the programming function starts from the moment of ‘calling’ it. As soon as the function is ‘called’, the program begins to perform the first statement inside the function. If needed, you can ‘call’ functions from the internal functions.
The programming function is described as follows - the keyword function, accompanied by a name, and by parentheses ().
The function combines a sequence of statements - function body. Any data or value can be passed to the function, and the function will return the value or data. It consists of a function header and a function body. The program always starts working from the top to the bottom. The program is divided into two functions - addition and main, where 'main' is called automatically. 'Addition' are produced if only 'are called' from main.
The name means the value which may subsist of letters, digits, dollars, and emphasizes. The parentheses contain parameter names divided by comma. It behaves as a regular variable. What’s inside the braces {} is a block of statements which specifies the task.
Related terms: CodingScripting, JavaScripting
References and further reading: