Functions in C – Types of functions

Functional programming languages –There are two types of functions in C programming language: Library Functions: are the functions which are declared in the C header files such as puts(), ceil(), floor()  scanf(), printf(), gets() etc. User-defined functions: are the functions which are created by the C programmer, so that it can use it many times.

functions in c is a piece of code, it functions like a sub-program in a program. When creating a program, sometimes we require that we have to use the result obtained from execution of some codes repeatedly in the program, in which case the codes are not written again and again as a function main ( ) Is defined outside the function and used in the same place. And the result obtained from the function is called to use that function in the program.

Function of syntax:-
function name(arg1, arg2, arg3….)

There are two types of functions in the programming language “c”. 

1: – Built-in-functions (built-in-functions)
2: – user defined functions

1: – Built-in-function : –

Built-in-functions are functions whose prototypes are preserved in the header file of the programming language “C”. These functions are called by simply typing their name in the program and it is executed in the program. Examples of this: – scanf ();, printf ();, strcat (); e.t.c.

These functions are also called library functions of the “C” programming language. All these functions are related to a specific “C” library file. These special library files are called header files and their extension name is .h. Therefore, all the files in the library of “C” which have an extended name .h are called header files.

string functions in c

Functions Description

isspace() Checks whether the character is space
islower() Checks whether character is lower case
isdigit() checks whether character is a digit
isalnum() Checks whether the character is alphanumeric

The following are several header files in “C”: –


2: – User-defined function –

string functions in c

User-defined functions are those which are created by the user while writing the program i.e. they are defined. The type of user needs can create a function according to their requirements. A main () function is required to write programs in the programming language “C”. This function is also a user-defined function. The execution of the program also starts with this program. The function can be named anything other than the keywords used in “C”.

A function can be called by any other function and in itself. It is necessary to put () braces after the function, it is an indicator of the function. The user writes its functionality, but also its declaration has certain restrictions. Main() in a pre-defined function from where the code execution starts in a program
main() is not a predefined or inbuilt function. this is a user-defined function with a predefined function prototype.

(Image source google search)

Author: Dewakar Pandey

Leave a Reply

Your email address will not be published.