A function is a group of statements that together perform a specific task. You can write all intended functionality at one place and call it wherever required.
Why use function ?
Function are used for divide a large code into module, due to this we can easily debug and maintain the code. For example if we write a calculator programs at that time we can write every logic in a separate function (For addition sum(), for subtraction sub()). Any function can be called many times.
Defining a function:
return_type function_name(parameter)
{
function body;
}
Calling a function:
function_name();
OR
variable=function_name(argument);
Advantage of Function: