C Function Prototype

A function prototype is also known as a function declaration which specifies the function’s name, function parameters, and return type. The function prototype does not contain the body of the function.  It is basically used to inform the compiler about the existence of the user-defined function which can be used in the later part of the program.

Syntax

return_type function_name (type1 arg1, type2 arg2, ... typeN argN);

We can also skip the name of the arguments in the function prototype. So,

return_type function_name (type1 , type2 , ... typeN);

 

User-Defined Function in C

A user-defined function is a type of function in C language that is defined by the user himself to perform some specific task. It provides code reusability and modularity to our program. User-defined functions are different from built-in functions as their working is specified by the user and no header file is required for their usage.

In this article, we will learn about user-defined function, function prototype, function definition, function call, and different ways in which we can pass parameters to a function.

Similar Reads

How to use User-Defined Functions in C?

To use a user-defined function, we first have to understand the different parts of its syntax. The user-defined function in C can be divided into three parts:...

C Function Prototype

A function prototype is also known as a function declaration which specifies the function’s name, function parameters, and return type. The function prototype does not contain the body of the function.  It is basically used to inform the compiler about the existence of the user-defined function which can be used in the later part of the program....

C Function Definition

Once the function has been called, the function definition contains the actual statements that will be executed. All the statements of the function definition are enclosed within { } braces....

C Function Call

In order to transfer control to a user-defined function, we need to call it. Functions are called using their names followed by round brackets. Their arguments are passed inside the brackets....

Example of User-Defined Function

The following C program illustrates how to use user-defined functions in our program....

Components of Function Definition

...

Passing Parameters to User-Defined Functions

There are three components of the function definition:...

Advantages of User-Defined Functions

We can pass parameters to a function in C using two methods:...