What is the function call in C Language
Categories: C language
Before jumping to the function call, we need to understand the function in the C programming language. A function is a group of tasks used to execute the predefined operations and returns a value. A large program can be divided into small blocks of code that help to understand the logic, debug, and modified it.
In the C programming language, the function is divided into two parts: the built-in/ library function and the user-defined function.
Library/ Built-in Function
A library function is predefined functions, and its tasks are also defined in the C header files. So, it does not require writing the code of the particular function; instead, it can be called directly in a program whenever it is required. Example: printf(), scanf(), getch(), etc., are the predefined function in the C library, and the meaning of these functions cannot be changed.
Let's write a program to define the library function in C.
Predefined.c
# include <stdio.h> // Contains the printf, scanf() built-in function
#include <conio.h>
void main()
{
printf( " Welcome to the JavaTpoint.com ");
printf("\n It is the library or built-in function in C ");
getch(); // built-in function
}
Output:
Welcome to the JavaTpoint.com
It is the library function or built-in function in C
User-defined Function
It is a user-defined function in the C programming language to execute some specific actions according to the programmer's requirement. A user-defined function is divided into three types such as function declaration, function definition, and function call.
Function Declaration
A function declaration defines the name and return type of a function in a program. Before using the function, we need to declare it outside of a main() function in a program.
Syntax:
return_data_type function_name ( data_type arguments) ;
Example of function declaration:
int add ( int num1, int num2 );
In the above example, int is a return data type of the function name add function that contains two integer parameters as num1 and num2. Furthermore, we can write the above function declaration is as follows:
int add (int, int);
Function Definition
It defines the actual body of a function inside a program for executing their tasks in C.
Syntax:
return_data_type function_name (argument list ) {
// Statement to be executed in a function;
}
In the above syntax, a function definition contains the three parts as follow:
1. Return Data_Type: It defines the return data type of a value in the function. The return data type can be integer, float, character, etc.
2. Function Name: It defines the actual name of a function that contains some parameters.
3. Parameters/ Arguments: It is a parameter that passed inside the function name of a program. Parameters can be any type, order, and the number of parameters.
4. Function Body: It is the collection of the statements to be executed for performing the specific tasks in a function.