Search PPTs

Tuesday, August 13, 2013

PPT On Function In C Language

Download

Function In C Language Presentation Transcript: 
1.What is a FUNCTION?Function is a self contained block of statements that perform a coherent task of some kind.
Every C program can be a thought of the
collection of functions.

2.TYPES OF FUNCTIONS
Library functions.
These are the in-built functions of ‘C’ library.
These are already defined in header files.
e.g. printf( );
is a function which is used to print
output. It is defined in‘stdio.h’file .

3.User defined functions
Programmer can create their own function in C to perform specific task.
e.g.
#include
main( )
{
message( );
}

message( )
{
printf(“Hello”);
}

4.Some conclusion
Any C Program must contain at least one function.
If program contains only one function it must be
main( ).
There is no limit on the number of functions
present in a C program
Each function in a program is called in the
sequence specified by functions call in main( ).
After each function has done its thing, control
returns to main( ). When main( ) run out of
function calls program ends
C Program is a collection of one or more functions.
       A function gets called when its name is followed by a semicolon.

5. Advantages
It felicitate top down modular program.
The length of the source program can be reduce by using functions at
It is easy to locate and isolate and fault function easily
A function can used by many other program, it means programmer built an what have already done, insert of starting over scratch.

6. Using Functions
Using Functions The main functions and other library functions does need to be declared and defined but the main function’s body need to be defined by the programmer.

7. The 3 components associated with functions are
The Declaration
The function definition
The Calling Statement

8.In C user- written functions should normally be declared prior to its use to allow compiler to perform type checking on arguments used in its call statement. The general form is: Return_data_type  function_name (data_type Variable_name);

9.Function name
This is the name given to the function. It follows the same naming convention as that of any valid variable in C.
Return data type: this specifies the type of data given back to the calling construct.
Data type list: this list specifies the data type of each variables, the values of which are expected to be transmitted to the function. These variables are known as formal parameters.

10.The collection of program statements that does a specific tasks done by the function is called the function definition. It consist of
function header: Int FindMax(int x, int y) { } 
function body. Int FindMax(int x, int y) { //body of the function…. }

11.The function is called from the main() The function can in turn call a another function. the function call statements invokes the function, which means the program control passes to that function. Once the function completes its task, the program control is passed back to the calling environment.
The general form of calling stmt is: Function_name (var1, var2,..); Or var_name=function name(var1, var2,..);

No comments:

Related Posts Plugin for WordPress, Blogger...

Blog Archive