There are two types of functions that we can use in the C language.
- Library functions
- User-defined functions
Library functions can be used by including the respective header file and then calling the function in the main body.
User-defined functions are the ones defined by the users as per their requirements.
Defining these is done in three steps:
- Declaring the function before “main”
For example, message();
Here “message” is the name of the function. Note that we have used statement terminator (;) here.
- Calling the function in the main.
For example,
main()
{
message();
}
Again here we need to use statement terminator.
- Defining the function after “main”
For example,
message(); —> 1
main()
{
message(); —> 2
}
message() —> 3
{
Printf (“Hello functions!!!”);
}
able on which decision will depend.