Analytics

A function is a group of statements which are collectively stated under one entity or one name, i.e. function name. A function contains many statements that need to be operated on. It can perform any operation like addition, subtraction or print certain statements or perform any logical operation etc. C program does not execute the functions directly. It is required to invoke or call that functions. When a function is called in a program then program control goes to the function body. Then, it executes the statements which are involved in a function body. Therefore, it is possible to call function whenever we want to process that functions statements.

Functions Provides us Following Features:

Reusability of Code: Means once a code has developed then we can use that code any time.Remove Redundancy: Means a user doesn’t need to write code again and again.Decrease Complexity: Means a Large program will be Stored in the two or more functions. So that this will makes easy for a user to understand that code.

Need of functions in C Language:

As we all know C is procedure oriented programming language and procedure or functions is like the building block of a C program. The entire C program is built with the help of many functions so that it becomes easy for everyone to understand it. The complexity or the difficulty of the program is even decreased since the program is divided into many modules or functions. The detection of errors is even simpler as we can track the error easily.

Advantages of functions:

• It is easy to use.• Debugging is more suitable for programs.• It reduces the size of a program.• It is easy to understand the actual logic of a program.• Highly suited in case of large programs.• By using functions in a program, it is possible to construct modular and structured programs.

Type of functions:

Functions are of two types

• Built in function or Library Functions

• User defined functions

Built in functions:

Built in functions are the functions that are provided by C library. Many activities in C are carried out using library functions. These functions perform file access, mathematical computations, graphics, memory management etc. A library function is accessed simply by writing the function name, followed by an optional list of arguments and header file of used function should be included with the program. Definition of built in functions are defined in a special header file. A header file can contain definition of more than one library function but the same function cannot be defined in two header files. These functions are stored in library files. Ex:

isdigit (): returns non-0 if arg is digit 0 to 9isalpha (): returns non-0 if arg is a letter of the alphabetisalnum (): returns non-0 if arg is a letter or digitislower (): returns non-0 if arg is lowercase letterisupper (): returns non-0 if arg is uppercase letter