• admin@embedclogic.com

Function in C

A set of statements written to perform any task is known as function.

Syntax –


In above example function, printNaturalNumber has

— set of statements to perform the printing of natural number.

— void input i.e no input parameter.

— void output i.e no output return.

Advantages of Function use

— Function’s use increases the program readability.

— Function’s use decreases the complexity.


A Program without use of function
A Program with use of function

So we can see in above example program is more readable and less complex with the use of functions.

Types of a function

In C language there are two types of function –

— Library defined functions

— User-defined function

Library defined functions

library defined functions are standard functions defined in the standard C library. We only need to include the header file prior to use of any standard function because header file contains the prototype of stnadard C functions.


the main function is defined in the standard library and its prototype declared in stdio.h header file.

printf() ,scanf(), getch(), gets() etc. all functions are standard and defined in a standard library.

User-defined function

User-defined function as the name appears –“A function defined by a user/programmer”. these functions are not standard and these are the project-specific functions written by a programmer to make program modular and less complex.

Above function is an user-defined function written by a programmer to print natural number.

Subscribe and stay updated with our latest articles.

You have successfully subscribed to the newsletter

There was an error while trying to send your request. Please try again.

Embedclogic will use the information you provide on this form to be in touch with you and to provide updates and marketing.