Documente Academic
Documente Profesional
Documente Cultură
Functions
Definition: Function is a self contain block of
statements, to perform a desired task.
Functions are classified into two types
1. Prototype of function
2. Function call
• It contains the body of the function that performs the operation of function.
Syntax:
returntype function_name(argument list)
{
…………
statements;
…………
}
Example:
int add(int a, int b)
{
…………
}
Basic program on functions
void display( void); //prototype of function
main()
{
printf(“\n This is main function”);
display(); // Function call
}
Void display (void) // definition of function
or called function
{
printf(“\n This is display function”);
}
Basic function designs
• We classify the four basic function designs by
their return values and their parameter lists
14
The C language uses only pass by value and return to
achieve three types of communications between
a calling and a called function.
15
Formal and Actual Parameters