|
C
program can be viewed as a block of building blocks called functions. A
function is a subroutine that may include one or more statement designed
to perform a specific task. To write a C program we first create a
function and then put them together. A C program may contain one or more
section as below.
| Documentation Section |
| Link Section |
| Definition Section |
| Global Declaration Section |
main() Function Section
{
Declaration Part
Executable Part
} |
Subprogram section
Function 1
Function 2
-
-
Function n |
Documentation section consist of set of comment, purpose of the program,
Program logic etc. The link section provide instruction to the compiler
to link function from the system library. The definition section define
all symbolic constants.
There are some variable that are used in more than one
function such variable are called global variable and are declared in
the global declaration section that is outside of the functions.
Every
C program must have one main() function section. This section contains
two parts declaration part and executable part. The declaration part
declare all the variable used in the executable part. There is at lest
one statement in the executable part. These two part must appear between
the opening and the closing brace. The program execution begin at the
opening braces and end in the closing brace. The closing brace of the
main function section is the logical end of the program. All statement
in the declaration section and executable parts end with
semicolon.
The
subprogram section contain all the user-defined function that are called
in the main function.User defined functions are generally placed
immediately after the main function. Although they may apper any order.
|