Saturday, May 10, 2008

Function And Recursion(Function Definition)

Function And Recursion


Function Definition

Functions are self contained program segments that carry
out some specific well defined task.

In "C" , we include the header files like stdio, conio, string, etc.

These files contain number of library functions which are as follows:

printf( ), scanf( ), getchar( ), putchar( ), getche( ),
gets( ), puts( ), strlen( ), getch( ), etc.

In C it is possible for the function to call themselves.
we will see how it can be possible through Recursions.

A Function is a self-contained block of statement that
perform a coherent task of some kind. Every C program must
have a function. One of the function must be main().

Why should we use Function?

a) Using function it becomes easier to write programs and
keep track of what they are doing

b) Length of the program can be reduced by using function.

c) Debugging is easier.

d) It facilitates top-down modular programming.

Classification of Function

C function can be classified into two categories:

1. Library function:

They are predefined in the standard library of C. We need
to include the Library.

2. User-defined function:

User defined functions are need to be developed by the user
at the time of program writing.

0 comments:

Copyright

Copyright © 2008 C Tutorial, All rights are reserved