Functions
Functions
❖ Declaration of a function:
A function declaration tells the compiler about a function's name, return type,
and parameters.
❖ Definition of a function:
A function definition provides the actual body of the function.
❖ Calling a function:
To use a function, you will have to call that function to perform the defined
task.
FUNCTION DECLARATION
❖ To call a function, you simply need to pass the required parameters along with the
function name, and if the function returns a value, then you can store the returned
value.
❖ When a program calls a function, the program control is transferred to the called
function.
❖ When its return statement is executed or when its function-ending closing brace is
reached, it returns the program control back to the main program.
FUNCTION DEFINITION
❖ Given below is the source code for a function called max(). This function takes two parameters
num1 and num2 and returns the maximum value between the two −
❖ A function that calls itself is known as a recursive function. And, this technique is known as
recursion.