C Program Basic Structure
Here you will learn the basic concepts of C
program.
The C program consists of six main sections. Below
you will find a brief explanation for each of them.
C program Basic Structure |
Documentation Section |
Link Section |
Definition Section |
Global Declaration Section |
Main() Function Section { . Declaration Section Executable Section } . |
Subprogram Section |
Basic C Program Structure
Documentation Section:
This section consists of a comment line that
includes the name of the programmer, the author and other details such as the
time and date of writing of the program. The Documentation section helps anyone
get an overview of the program.
Link Section:
The link section consists of the header files of the
functions used in the program. It gives the compiler instructions on how to
link functions from the system library.
Definition Section:
All of the symbolic constants are written in the
definition section. Macros is known as symbolic constants.
Global Declaration Section:
Global variables that can be used anywhere in the
program are stated in the Global Declaration section. The user defined
functions are also declared in this section.
main() Function Section:
It is necessary to have one main) (function section
in each C program. This section includes two parts, a declaration and an
executable part. The declaration part declares all the variables used in the
executable part. These two parts must be written between the opening and the
closing braces. Each declaration and executable part of the declaration must
end with a semicolon (;). The execution of the program starts with the opening
of the braces and ends with the closing braces.
Subprogram Section:
The subprogram section contains all user defined
functions used to perform a specific task. In the main ( ) function, these user
defined functions are called.
No comments:
Post a Comment
Thanks