In C programming language, a function declaration is a statement that informs the compiler about the presence of a function without giving implementation details. It usually contains the function name, return type, and the parameter types. A function declaration tells the compiler that there is a function with the given name defined somewhere else in the program. The parameter name is not mandatory while declaring functions, and we can also declare the function without using the name of the data variables.
A function definition, on the other hand, consists of actual statements that are executed when the function is called. It provides the actual body of the function. A C function is generally defined and declared in a single step because the function definition always starts with the function declaration, so we do not need to declare it explicitly.
The general form of a function definition in C programming language is as follows:
return_type function_name(parameter_list) {
body of the function
}
Here, the return_type is the data type of the value returned by the function, function_name is the name of the function, and parameter_list is the list of parameters passed to the function.
Its worth noting that function declarations do not include the function body, which includes the actual code that runs when the function is invoked. The body of the function is defined independently of the function statement, usually in a separate block of code called the function definition.
In summary, a function declaration in C programming language is a statement that informs the compiler about the presence of a function without giving implementation details, while a function definition provides the actual body of the function.