Function Definition : The program module that is written to achieve a specific task is called function definition.
Syntax : type function-name(parameter list) // function header.
{
declaration of variables;
body of function; // Function body
return statement;
}
Where
type : return type can be int ,float,double,void etc. This is the type of the value that the function is expected to
return. If the function is not returning any value, then we need to specify the return types as void.
function-name : is the name of the function.
parameter-list : Parameter list declares the variables that will receive the data sent by the calling program.
Example of User Defined Function :
#include<stdio.h>
void add(); //function declaration/prototype
void main()
{
add(); //Function call
}
void add() // function definition
{
int a,b,c;
printf(“Enter the values of a and b”);
scanf(“%d%d”,&a,&b);
c=a+b;
printf(“%d”,c);
}