0% found this document useful (0 votes)
227 views

Structure of A C Program

Every C program consists of functions, with one function called main() that is executed first. A C program is divided into 6 sections: the Documentation Section contains comments, the Link Section provides instructions to link libraries, the Definition Section defines constants, the Global Declaration Section defines global arguments, the main() Function Section has a declaration and executable part, and the Sub-program Section contains user-defined functions called in main().

Uploaded by

sonu1070
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
227 views

Structure of A C Program

Every C program consists of functions, with one function called main() that is executed first. A C program is divided into 6 sections: the Documentation Section contains comments, the Link Section provides instructions to link libraries, the Definition Section defines constants, the Global Declaration Section defines global arguments, the main() Function Section has a declaration and executable part, and the Sub-program Section contains user-defined functions called in main().

Uploaded by

sonu1070
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 2

DIAGRAM

Documentation Section

Link Section

Definition Section

Global Declaration Section


Declaration Part
main() FunctionPart
Executable Section
{

}
Function1
Subprogram Section
Function2
. .
.
(User-defined Functions)
.
Function3

Every C program consists of one or more modules called functions. One of the
functions must be called main (). The program will always begin by executing the main
function, which may access other functions. A program consists of one or more functions.
It may also contain global variables. The “C” program is divided into 6 sections:

Documentation Section-
It consists of a set of comment lines giving the name of the program & other
details, which can be given by the user. The comment may appear anywhere within a
program, as long as they are placed within the delimiters.

/* -------- */ (For Multiple lines)


// ---------- (For Single lines)
Link Section-
This section provides instruction to the compiler to link the functions from the
system libraries.

#include<stdio.h>

Definition Section-
This section defines all the symbolic constants that user can define in macro
submission.

Global Declaration Section-


In this section the user can define the arguments for whole C program. There are
some variables that are used in one or more than one function; such variables are called
global variables.

Main Function Section-


Every C program must have one main () function. It contains two parts named as
declaration part and executable part. The declaration part declares the variables used in
the executable part. There is at least one statement in the executable part.

Sub-program Section-
The sub-program section contains all the user-defined function that is called in the
main () function. The user-defined function generally called sub-routines. This function
generally placed immediately after the main function.

You might also like