Types of user defined function – free C programming tutorial

In this tutorial, you will get familiarise to types of user defined function available for C programming language.

A function in C is defined as a group of code or statements that performs a specific task.

So we are dividing complex problem into small divisions which makes program easy to understand and use by creating functions.

Types of functions in C programming :

There are two types of functions in C programming language depending on whether a function is defined by the user or already included in C compilers:

  • Predefined functions : The predefined functions are built-in functions in C language. They are used to handle the tasks such as mathematical and logical calculations, I/O processing etc.
    Predefined functions are defined in the header file. When you include the header file, these functions are available for use.For example:
    The printf() is a standard library function defined in “stdio.h” header file. This function is used to send compiled output to the console ( output screen).
  • User-defined functions : C language allow programmers to define function . Such functions which are created by the user are called user-defined functions.
    Depending upon requirements of the program, you can create as many user-defined functions as you want.For example:
    int add();
    int is a return type in the above statement i.e. function add will return an integer value.

Types of user defined function in c :

User defined functions can be further divided into four types of user defined function on the basis if return type and parameters are present or not that are given as following :

  1. Function with no arguments and no return value
    For example :
    void add();
  2. Function with no arguments and a return value
    For example :
    int add();
  3. Function with arguments and no return value
    For example :
    void add(num1 , num2);
  4. Function with arguments and a return value
    For example :
    int add(num1 , num2);

If you have any doubt please comment below.

Leave a Comment

Your email address will not be published. Required fields are marked *