In real time, a function may be defined with or without parameters and a function may or may not return a value. It completely depends upon the user requirement. In this article, We will explain you the types of functions in C Programming language with an example.
In C Programming, As per our requirement, We can define the User-defined functions in multiple ways. The following are list of available types of Functions in C
Function with no argument and no Return value
Function with no argument and with a Return value
Function with argument and No Return value
Function with argument and Return value
NOTE:
From the above, 1 and 3 types does not return any value when the function is called. So, We use void return type while defining the function.
When we call the function 2 and 4 types will return some value. So, We have to use the appropriate data type (int, float, double etc) as return type while defining the function. We use return keyword inside the function to return some value when the function is called from the main() function or any sub-functions.
Types of Functions in C Programming
The Following examples will explain you the available function types in C programming.
C Function with No argument and No Return value
In this method, We won’t pass any arguments to the function while defining, declaring or calling the function. This type of functions in C will not return any value when we call the function from main() or any sub function. When we are not expecting any return value but, we need some statements to be printed as output then, this type of functions in C are very useful.