Basic Structure of C Program

Documentation Section
Link Section
Definition Section
Global Declaration Section
               main()
               {
declaration part;
execution part;
                }
Subprogram section()
             {
declaration part;
execution part;
             }


Documentation section

It is also called as block comment. It is used when the comment will span several lines. It contains the name of the program, author of the program, etc. Documentation Section we can write any where in the program. Documentation Section we write in /* and */. With in /* and */ we can write many no. of lines.

Link section

# include is the link section or source file or header file. # is a preprocessor. The Preprocessor command tells the compiler to include the stdio.h file in the program. include is a directive. Include means just what you would think it does. 
Std means standard.
I means input.
O means output.
H means header file.
Preprocessor helps to link to header file.


Definition section


We can define anything in the definition section. Like values, variables, expressions, predefined statements. 
Syntax:- #define constantname value
Ex:- #define PI 3.14
Constant values means we can make user defined as constants and predefined also according to the requirement.


Global declaration section

If you declare and define any variable we can use through out the program no. of times.


main()

Program execution stars from the main(). Without main() our programs won’t run. Main() contains 3 arguments by default. Argc, argv, env. Main() contains declaration part and executable part. Declaration part is always top. After the declaration part we can write executable part.
main()
{
Local Declaration part;
Executable part;
}

Sub function section

It contains declaration part and executable part just like a main(). But it is user defined. We can write many no. of user defined functions.

No comments:

Post a Comment