-Functions are the group of the statement which can work as single unit to perform one specific task.
Benifits of using Functions:
-reusability of the code.
-Structured code.
-error detection is easy.
Syntax-
type name()
{
body
return;
}
Types of the function on the basis of syntax:
1. Function with no argument and no syntax
2. Function with no argument and have return value.
3. Function with argument and No return Value.
4. Function with argument and Return value.
Build-In Function:
These are the functions which are predefined in the heador files like : main(),printf(), scanf(), gets().
-main() is the predefined function and execution of every program starts with the main() function.
User-Defined Function:
These function are created by the programmer while write our own code.
program-
#include< stdio.h>
void function() //definition
{
printf("You make the function\n");
}
int main()
{
printf("Inside main function\n");
function(); //calling
function();
return 0;
}
output-
Inside main function
You make the function
You make the function
-In this program, we create a function named as function() and it have not any return type because of 'void'
"You make the function" this statement are run two time because we call function() two times inside the main() function.