Home Tutorials C Tutorial Function Types
Function Types

Function Types


Types of Functions in C

Categorization of Functions

Functions in C are generally categorized into two main groups based on their origin, and further classified into four types based on their parameters and return values.

1. Library Functions

Pre-defined functions in C header files.
Examples: printf(), scanf(), sqrt().

2. User-Defined Functions

Functions created by the programmer to perform specific tasks tailored to their program.

The 4 Variations of User-Defined Functions

Depending on whether a function takes input (arguments) and gives output (return), we have these four types:

Type Description
Type 1 No Argument & No Return Value
Type 2 With Argument & No Return Value
Type 3 No Argument & With Return Value
Type 4 With Argument & With Return Value

Coding Examples

Type 1: No Argument, No Return

void checkEven() {
    int n = 4;
    if(n % 2 == 0) printf("Even");
}

Type 2: With Argument, No Return

void printSquare(int n) {
    printf("%d", n * n);
}

Type 3: No Argument, With Return

int getPI() {
    return 3; 
}

Type 4: With Argument & Return

int sum(int a, int b) {
    return a + b;
}
Which one to use? Most professional code uses Type 4. It is the most flexible because it keeps the function "pure"—it takes specific inputs and gives a specific output without relying on global variables.

🏋️ Test Yourself With Exercises

Take our quiz on Function Types to test your knowledge.

Browse Quizzes »