Functions in C language.

Functions in C language.

Learn from voice....

16/01/2021 7:28AM

Episode Synopsis "Functions in C language."

A function is a block of code that performs a specific task. For example, the main is function and every program execution starts from main function. The C program is made of one or more functions. Every program must have at least one function with the name main. The execution of the program always starts from main function and ends with main function. Main function can call other functions to do some special task. The function is a small program is used to do a particular task. In C language a big program divided into several small subroutines/functions/procedures. So, C language is a function-oriented programming language. C language supports two types of functions. Standard Library functions. User-defined functions. Standard Library functions. The Standard Library functions are inbuilt or pre-defined functions. There are some problems which are common to all programmers like displaying characters to the screen, taking input from the end-user, finding square root values of a number. For the solution of these common problems some pre-defined functions already given. These pre-defined functions were written by the creator of the C language. These functions are defined in the header file. When we include a header file in our program then all the functions available in that header file are accsessable. User-defined functions In addition to standard library functions supplied by the system, C language allows programmers to write their own functions for a specific work to accomplish. A function defined by the user to accomplish a task is called a user-defined function. Advantage of user-defined functions. 1) Modularity:- Dividing a big program into small modules. Using functions, the problem can be divided into small understandable and manageable steps. 2) Reusability:- Write once, use many times. Functions avoid repeating code in a program. One function can be called and used in several places. For example printf function, the printf function is defined only one time in stdio.h header file, but we use it many times in our program. 3) Simplicity:- Easy to read instructions. Using functions our program becomes very simple and understandable. 4) Efficiency:- Program performance increased. Usage of functions reduces the amount of work and development time. Using functions we can easily find the errors in our program. Another benefit of using the function is different programmers working on one large project can divide the workload by writing different functions. Functions can be used to protect data. This is related to the concept of local data. Local data is the data described within a function. They are available only within a function when the function is being executed.

Listen "Functions in C language."

More episodes of the podcast Learn from voice....