Definition Definition

Function

In programming, a function is a procedure that performs a specific task. It is a named block of code that can be called several times, from several different places, during a single execution of a program.

Most programming languages have prewritten set of functions called default functions that are kept in a library. One can also write one's own functions which is called user defined function to perform specialized tasks.

A function may have the following parts:

 - Function Name: The functions must have name and the name follow the naming conventions. 

 - Return Type: Returning data type of the function (void, integer, char, float etc.).

 - Parameters or Arguments: Parameters are placeholders that are passed into the function.

 - Function Body: Collection of statements that defines what the function actually does.

Example:

Function in C programming.

int print_result(int num1, int num2) 
{
   int result;
   result=num1+num2;
 
   return result; 
}
Share it: CITE

Related Definitions