Function in C:
Requirement: Visual studio code, MinGW and installation of C/C++ extension in visual studio code
A function is a block of code that performs a particular task.
Function Type:
i) Standard library functions: example: printf(),sqrt(), gets(),……
ii) user-defined function
User-defined function:
You can create functions as per your requirement.
Such function is called user-defined functions.
Syntax:
return_type function_name (parameters...)
{
//body of the function
}
And calling this function into a program like:
// Calling sum function
return_type function_name (parameters...);
Example:
include here header file sdio.h
int sum(int a, int b)// funtion defintion created by user
{
return a + b;
}
int main()
{
int a=10;
int b=20;
int total = sum(a, b);// function calling
printf("Sum is: %d", total);
return 0;
}