A computer program (except for the simplest one) cannot handle all the tasks by itself. Instead, it requests other program like entities—called ‘functions’ in C—to get its tasks done.

A function is a self-contained block of statements that perform a coherent task of some kind.

Example

main( )

{

message( ) ;

printf ( "\nCry!" ) ;

}

message( )

{ printf ( "\nSmile" ) ;

}

And here’s the output...

Smile...

Cry

Here, main( ) itself is a function and through it we are calling the function message( ). Main( ) ‘calls’ the function message( ) and it mean that the control passes to the function message( ).

The activity of main( ) is temporarily suspended; it falls asleep while the message( ) function wakes up and goes to work. When the message( ) function runs out of statements to execute, the control returns to main( ), which comes to life again and begins executing its code at the exact point where it left off. Thus, main( ) becomes the ‘calling’ function, whereas message( ) becomes the ‘called’ function.

Important points about Function

Any C program contains at least one function.

If a program contains only one function, it must be main( ).

If a C program contains more than one function, then one (and only one) of these functions must be main( ), because program execution always begins with main( ).

There is no limit on the number of functions that might be present in a C program.

Each function in a program is called in the sequence specified by the function calls in main( ).

After each function has done its thing, control returns to main( ).

When main( ) runs out of function calls, the program ends. The program execution always begins with main( ). Except for this all C functions enjoy a state of perfect equality. No precedence, no priorities.

One function can call another function it has already called but has in the meantime left temporarily in order to call a third function which will sometime later call the function that has called it.

Other C programming Related topics are

Switch in C Programming
PROGRAMMING C VARIABLES
C PROGRAM INSTRUCTIONS
COMPILATION AND EXECUTION OF C PROGRAM
C PROGRAMMING RULES PART ONE
C PROGRAMMING RULES PART TWO
COMPILATION AND EXECUTION OF C PROGRAM
INSTRUCTIONS TO WRITE C PROGRAM

Other Programming Courses :

ASP.NET part one and two
Programming with C and C Sharp
Dot Net Complete Course Part one and two
Interview Questions in dot net and asp.net part one part two
Software Testing Complete course part one and two
Interview Questions in software Testing
Complete software testing course here as basic and advanced parts .

Team blog recent posts

Work Flow in SAP ABAP an introduction
ABAP Syntax for Move corresponding
Zeroth law of thermodynamics (physics)

Thank you for visiting Codes and Test. To get the updates as and when published, please subscribe to my blog via email or RSS FEED.You can mail me at d_vsuresh[at the rate of ]yahoo[dot]co[in] for specific feed backs and suggestions.

0 comments

Post a Comment