Functions In C

12 February 20120 comments

If an operation has to be performed at many times at many different places in a program then the programmer writes the same set of instructions as many times as it is required.For example , in a program that computes the factorial in many different places of the program , then it would be wasteful of the programmers time and effort to write the same set of instructions again and again.This activity not only increases the size of the program but also adds the chances of making the typographical mistakes.
A better way to achieve the same effect would be to use subprograms or functions.A subprogram or a function is a name given to a set of instructions that can be called by the another program or a subprogram.This technique simplifies the programming process.

The general form of the function is given below: 
<type> name (arguments)
{

      body of the function;

}

where <type> is the type of the value to be returned by the function.
name   is an user defined name of the function
Share this article :

Post a Comment

 
Copyright © 2011. All Compiler - All Rights Reserved