Presentation is loading. Please wait.

Presentation is loading. Please wait.

Function There are two types of Function User Defined Function

Similar presentations


Presentation on theme: "Function There are two types of Function User Defined Function"— Presentation transcript:

1 Function There are two types of Function User Defined Function
Library Function

2 Function Function is a group of statements as single unit known by some name which is performing some well defined task. The functions which are created by a programmer in a program are called as user Defined function, whereas the functions which are readily available in library are called as Library functions or Built in functions.

3 Advantages of Function
Functions facilitates top-down modular programming, whereby the large problem is divided into small parts and each small parts is handled later in depth It reduces the size of code, if that code is repeated in the program. Function can be used in other program also, so labor is reduced.

4 Function can call itself, which is called recursion, it reduces the coding, some problems are recursive in nature , at that place recursion can be used. It allow team work for large project, individual members of team has to concentrate on the function given to them and not on the whole complex problem

5 Category of Function The function in ‘C’ language can be divided into following categories: Function with no arguments and no return value. Function with arguments and no return value. Function with arguments and with return value.

6 There are Two types of scope: Local Variables Global Variables
Scope of Variables: There are Two types of scope: Local Variables Global Variables

7 Local Variables: The Variables which are declared inside the body of any function are called as Local variables For that function . These Variables cannot be accessed outside the function in which they are declared. thus, Local Variables are internal to the function in which they are defined.

8 Global Variables: The Variables which are declared outside any Function definition is called as Global Variable. These variables are accessible by all functiona in that program, i.e. All the function in program can share global variable.

9 Parameter passing to Function
When a function is called from other function, the parameters can be passed in Two ways: Call by Value Call by Reference

10 In call by value, Argument values are passed to the function, the content of actual parameters are copied into the formal parameter. The called function can not change the value of the variables which are passed.

11 Call by Reference, as the name suggest, the reference of the parameter i.e. address is passed to the function and not the value. Call by reference is used whenever we want to change the value of local variables declared in one function to be changed by other Function.


Download ppt "Function There are two types of Function User Defined Function"

Similar presentations


Ads by Google