What is a Function ? Explain Different types of Functions?


Functions are a self contained block of code that performs a particular false. A function can take some data from the main program, and returns a value.

The large program is divided into functional parts, and then each part may be independently coded and later combined into a single unit. These independently coded programs are called programs and are referred as function.

C functions can be classified into 2 categories, namely

   1.    library functions and
   2.    User –defined functions

main ( ) is an example of user defined function.

printf & scanf belong to the category of library functions.

The main difference between these two categories is that library functions are not required to be written by us, Whereas a user defined function has to be developed by the user at the time of writing a program.

Advantages of Functions:

1.When the program may become too large and complex and as a result the task of debugging, testing, and maintaining becomes difficult.

If a program is divided into functional parts, then each part may be independently coded and later combined into a simple unit.

These independently coded programs are called subprograms that are much easier to understand, debug, and test.

2.In some situations, we may repeat the program statements at many points throughout a program.

In such case, if you design a function that can be called used whenever required. This saves both time and space.

The length of source program can be reduced by using fns at appropriate places.

3.It is easy to locate and isolate a faulty function for further investigations.

4. A function may be used by many other programs. A user –defined function can later become a part of the C program library

functions


Top down modular programming using functions.




Related

Write about Command Line Arguments?

Command line argument is a parameter supplied to a program when the program is invoked. We know that every C program should have one main fn.& it can also take argu...

Write about Bit Fields in C?

The number of bits required for the structure variable is equal to the sum of the number of bits required for reach field. The structure allows us to specify the number...

How to Copy and Compare Structure Variables?

Two variables of the same structure type can be copied the same way as ordinary variables. If persona1 and person2 belong to the same structure, then the following statements...

Post a Comment

emo-but-icon
:noprob:
:smile:
:shy:
:trope:
:sneered:
:happy:
:escort:
:rapt:
:love:
:heart:
:angry:
:hate:
:sad:
:sigh:
:disappointed:
:cry:
:fear:
:surprise:
:unbelieve:
:shit:
:like:
:dislike:
:clap:
:cuff:
:fist:
:ok:
:file:
:link:
:place:
:contact:

item