CHAPTER OUTLINE
10.1
Introduction
10.2
Definition of a Function
10.3
Declaration of a Function
10.4 The Return Statement
10.5
Types of Functions
10.6
Call by Value and Reference
10.7
Function Returning More Values
10.8
Function as an Argument
10.9
Functions with Arrays and Pointers
10.10
Recursion
Exercises
10.1 INTRODUCTION
The programs written in C language are highly dependent on functions. A C program is nothing
but a combination of one or more functions. Every C program starts with the user-defined function
main (). Each time a new program is started, main () function must be defined, main () calls
another function to share the work.
The C language supports two types of functions: 1) Library functions and 2) User-defined functions.
The library functions are a pre-defined set of functions. Their task is limited. The user cannot
understand the internal working of these functions. The user can only use the functions but cannot
change or modify them. For example, s q r t (91) gives result 9. Here, the user need not worry about
its source code, but the result which is provided by the function.
The user-defined functions are totally different. The functions defined by the user according to
his/her requirement are called user-defined functions. The user can modify the function according
to the requirement. The user certainly understands the internal working of the function and has
full scope to implement his/her own ideas in the function. Thus the set of such user-defined functions
can be useful to a programmer. One should include the file in which the user-defined functions are
stored to call the function in the program. Example, let square (9) be a user-defined function that
gives the result 81. Here the user knows the internal working of the squ a re () function, as its
source code is visible. This is the major difference between the two types of functions.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.14.251.57