What are the Functions in C Language ??? with Free Notes

What are the Functions in C ???

Functions – If an operations has to be performed at many different places in a program then the programmer writes the same set of instructions as many times as it required. For Example, in a program that computes area of triangle in different parts of a program, it would be wasteful of programmer’s time and effort to code the same sequence of instruction every time it is required. This activity not only increases the size of the program but also adds the chances of making typographical mistakes.

A better way to achieve the same effect, however would be to use subprograms or functions. A subgroup or function is a name given to a set of instruction that can be called by another program or a subgroup. This technique simplifies programming process because a single set of instructions in the form of a subgroup is being used for all instances of computational requirements with data changing. Whenever the task is to be done, the control is transferred back to the normal program flow.

Play Quiz to Boost Knowledge

A Function is a complete program in itself, in the sense that its structure is similar to C main() function except that the name main() is replaced by the name of the function.

The General Form of the Function is given below:

<type> name (arguments)
{
......
}
  • <type> is the type of value to be returned by the function. If no value is returned then keyword void should be used.
  • name is an user defined name of the function. The function can be called from another function by this name.
  • arguments is a list of parameters. This can be omitted also by leaving the parameters apply.
Free Hand-Written Notes

The Program segment enclosed within the opening brace and closing brace is known as the function body.

Every C Program consists of one or more functions. On of the function must be main(). The execution of the program always begins with main(). No function can work independently but they have to be called in main() fucntion.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top